Compare commits
No commits in common. "3e9a7e45c4b3cc9ff09ec03ecc64712624179896" and "231024ba42851d991cf5ad7f18633b57dab07cbd" have entirely different histories.
3e9a7e45c4
...
231024ba42
3
.github/dependabot.yml
vendored
3
.github/dependabot.yml
vendored
@ -13,9 +13,10 @@ updates:
|
|||||||
- dependency-name: "com.puppycrawl.tools:checkstyle"
|
- dependency-name: "com.puppycrawl.tools:checkstyle"
|
||||||
# Newer versions have issues, see #1909 and #2050
|
# Newer versions have issues, see #1909 and #2050
|
||||||
- dependency-name: "jline:jline"
|
- dependency-name: "jline:jline"
|
||||||
# Needs to be synchronised with maven-resolver-provider dependencies
|
# 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-connector-basic"
|
||||||
- dependency-name: "org.apache.maven.resolver:maven-resolver-transport-http"
|
- 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
|
# Used with maven-resolver dependencies; 2.0 update breaks other providers
|
||||||
- dependency-name: "org.slf4j:slf4j-api"
|
- dependency-name: "org.slf4j:slf4j-api"
|
||||||
update-types: ["version-update:semver-major"]
|
update-types: ["version-update:semver-major"]
|
||||||
|
2
.github/workflows/maven.yml
vendored
2
.github/workflows/maven.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-java@v4
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: zulu
|
distribution: zulu
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
|
10
api/pom.xml
10
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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-API</name>
|
<name>BungeeCord-API</name>
|
||||||
@ -51,21 +51,21 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-resolver-provider</artifactId>
|
<artifactId>maven-resolver-provider</artifactId>
|
||||||
<version>3.9.6</version>
|
<version>3.8.5</version>
|
||||||
<!-- not part of the API proper -->
|
<!-- not part of the API proper -->
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.resolver</groupId>
|
<groupId>org.apache.maven.resolver</groupId>
|
||||||
<artifactId>maven-resolver-connector-basic</artifactId>
|
<artifactId>maven-resolver-connector-basic</artifactId>
|
||||||
<version>1.9.18</version>
|
<version>1.7.3</version>
|
||||||
<!-- not part of the API proper -->
|
<!-- not part of the API proper -->
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.resolver</groupId>
|
<groupId>org.apache.maven.resolver</groupId>
|
||||||
<artifactId>maven-resolver-transport-http</artifactId>
|
<artifactId>maven-resolver-transport-http</artifactId>
|
||||||
<version>1.9.18</version>
|
<version>1.7.3</version>
|
||||||
<!-- not part of the API proper -->
|
<!-- not part of the API proper -->
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -2,9 +2,7 @@ package net.md_5.bungee.api.connection;
|
|||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import net.md_5.bungee.api.config.ListenerInfo;
|
import net.md_5.bungee.api.config.ListenerInfo;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a user attempting to log into the proxy.
|
* Represents a user attempting to log into the proxy.
|
||||||
@ -91,26 +89,4 @@ public interface PendingConnection extends Connection
|
|||||||
* @return Whether the client is using a legacy client.
|
* @return Whether the client is using a legacy client.
|
||||||
*/
|
*/
|
||||||
boolean isLegacy();
|
boolean isLegacy();
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets if this connection has been transferred from another server.
|
|
||||||
*
|
|
||||||
* @return true if the connection has been transferred
|
|
||||||
*/
|
|
||||||
@ApiStatus.Experimental
|
|
||||||
boolean isTransferred();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a cookie from this pending connection.
|
|
||||||
*
|
|
||||||
* @param cookie the resource location of the cookie, for example
|
|
||||||
* "bungeecord:my_cookie"
|
|
||||||
* @return a {@link CompletableFuture} that will be completed when the
|
|
||||||
* Cookie response is received. If the cookie is not set in the client, the
|
|
||||||
* {@link CompletableFuture} will complete with a null value
|
|
||||||
* @throws IllegalStateException if the player's version is not at least
|
|
||||||
* 1.20.5
|
|
||||||
*/
|
|
||||||
@ApiStatus.Experimental
|
|
||||||
CompletableFuture<byte[]> retrieveCookie(String cookie);
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package net.md_5.bungee.api.connection;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import net.md_5.bungee.api.Callback;
|
import net.md_5.bungee.api.Callback;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
@ -14,7 +13,6 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
|||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||||
import net.md_5.bungee.api.score.Scoreboard;
|
import net.md_5.bungee.api.score.Scoreboard;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a player whose connection is being connected to somewhere else,
|
* Represents a player whose connection is being connected to somewhere else,
|
||||||
@ -341,45 +339,4 @@ public interface ProxiedPlayer extends Connection, CommandSender
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
Scoreboard getScoreboard();
|
Scoreboard getScoreboard();
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a cookie from this player.
|
|
||||||
*
|
|
||||||
* @param cookie the resource location of the cookie, for example
|
|
||||||
* "bungeecord:my_cookie"
|
|
||||||
* @return a {@link CompletableFuture} that will be completed when the
|
|
||||||
* Cookie response is received. If the cookie is not set in the client, the
|
|
||||||
* {@link CompletableFuture} will complete with a null value
|
|
||||||
* @throws IllegalStateException if the player's version is not at least
|
|
||||||
* 1.20.5
|
|
||||||
*/
|
|
||||||
@ApiStatus.Experimental
|
|
||||||
CompletableFuture<byte[]> retrieveCookie(String cookie);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores a cookie in this player's client.
|
|
||||||
*
|
|
||||||
* @param cookie the resource location of the cookie, for example
|
|
||||||
* "bungeecord:my_cookie"
|
|
||||||
* @param data the data to store in the cookie
|
|
||||||
* @throws IllegalStateException if the player's version is not at least
|
|
||||||
* 1.20.5
|
|
||||||
*/
|
|
||||||
@ApiStatus.Experimental
|
|
||||||
void storeCookie(String cookie, byte[] data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Requests this player to connect to a different server specified by host
|
|
||||||
* and port.
|
|
||||||
*
|
|
||||||
* This is a client-side transfer - host and port should not specify a
|
|
||||||
* BungeeCord backend server.
|
|
||||||
*
|
|
||||||
* @param host the host of the server to transfer to
|
|
||||||
* @param port the port of the server to transfer to
|
|
||||||
* @throws IllegalStateException if the players version is not at least
|
|
||||||
* 1.20.5
|
|
||||||
*/
|
|
||||||
@ApiStatus.Experimental
|
|
||||||
void transfer(String host, int port);
|
|
||||||
}
|
}
|
||||||
|
@ -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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Bootstrap</name>
|
<name>BungeeCord-Bootstrap</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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Chat</name>
|
<name>BungeeCord-Chat</name>
|
||||||
|
@ -20,10 +20,38 @@ public abstract class BaseComponent
|
|||||||
BaseComponent parent;
|
BaseComponent parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The component's style.
|
* The color of this component and any child components (unless overridden)
|
||||||
*/
|
*/
|
||||||
@Getter
|
private ChatColor color;
|
||||||
private ComponentStyle style = new ComponentStyle();
|
/**
|
||||||
|
* The font of this component and any child components (unless overridden)
|
||||||
|
*/
|
||||||
|
private String font;
|
||||||
|
/**
|
||||||
|
* Whether this component and any child components (unless overridden) is
|
||||||
|
* bold
|
||||||
|
*/
|
||||||
|
private Boolean bold;
|
||||||
|
/**
|
||||||
|
* Whether this component and any child components (unless overridden) is
|
||||||
|
* italic
|
||||||
|
*/
|
||||||
|
private Boolean italic;
|
||||||
|
/**
|
||||||
|
* Whether this component and any child components (unless overridden) is
|
||||||
|
* underlined
|
||||||
|
*/
|
||||||
|
private Boolean underlined;
|
||||||
|
/**
|
||||||
|
* Whether this component and any child components (unless overridden) is
|
||||||
|
* strikethrough
|
||||||
|
*/
|
||||||
|
private Boolean strikethrough;
|
||||||
|
/**
|
||||||
|
* Whether this component and any child components (unless overridden) is
|
||||||
|
* obfuscated
|
||||||
|
*/
|
||||||
|
private Boolean obfuscated;
|
||||||
/**
|
/**
|
||||||
* The text to insert into the chat when this component (and child
|
* The text to insert into the chat when this component (and child
|
||||||
* components) are clicked while pressing the shift key
|
* components) are clicked while pressing the shift key
|
||||||
@ -125,31 +153,31 @@ public abstract class BaseComponent
|
|||||||
}
|
}
|
||||||
if ( retention == FormatRetention.FORMATTING || retention == FormatRetention.ALL )
|
if ( retention == FormatRetention.FORMATTING || retention == FormatRetention.ALL )
|
||||||
{
|
{
|
||||||
if ( replace || !style.hasColor() )
|
if ( replace || color == null )
|
||||||
{
|
{
|
||||||
setColor( component.getColorRaw() );
|
setColor( component.getColorRaw() );
|
||||||
}
|
}
|
||||||
if ( replace || !style.hasFont() )
|
if ( replace || font == null )
|
||||||
{
|
{
|
||||||
setFont( component.getFontRaw() );
|
setFont( component.getFontRaw() );
|
||||||
}
|
}
|
||||||
if ( replace || style.isBoldRaw() == null )
|
if ( replace || bold == null )
|
||||||
{
|
{
|
||||||
setBold( component.isBoldRaw() );
|
setBold( component.isBoldRaw() );
|
||||||
}
|
}
|
||||||
if ( replace || style.isItalicRaw() == null )
|
if ( replace || italic == null )
|
||||||
{
|
{
|
||||||
setItalic( component.isItalicRaw() );
|
setItalic( component.isItalicRaw() );
|
||||||
}
|
}
|
||||||
if ( replace || style.isUnderlinedRaw() == null )
|
if ( replace || underlined == null )
|
||||||
{
|
{
|
||||||
setUnderlined( component.isUnderlinedRaw() );
|
setUnderlined( component.isUnderlinedRaw() );
|
||||||
}
|
}
|
||||||
if ( replace || style.isStrikethroughRaw() == null )
|
if ( replace || strikethrough == null )
|
||||||
{
|
{
|
||||||
setStrikethrough( component.isStrikethroughRaw() );
|
setStrikethrough( component.isStrikethroughRaw() );
|
||||||
}
|
}
|
||||||
if ( replace || style.isObfuscatedRaw() == null )
|
if ( replace || obfuscated == null )
|
||||||
{
|
{
|
||||||
setObfuscated( component.isObfuscatedRaw() );
|
setObfuscated( component.isObfuscatedRaw() );
|
||||||
}
|
}
|
||||||
@ -238,29 +266,6 @@ public abstract class BaseComponent
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the {@link ComponentStyle} for this component.
|
|
||||||
* <p>
|
|
||||||
* Unlike {@link #applyStyle(ComponentStyle)}, this method will overwrite
|
|
||||||
* all style values on this component.
|
|
||||||
*
|
|
||||||
* @param style the style to set, or null to set all style values to default
|
|
||||||
*/
|
|
||||||
public void setStyle(ComponentStyle style)
|
|
||||||
{
|
|
||||||
this.style = ( style != null ) ? style.clone() : new ComponentStyle();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set this component's color.
|
|
||||||
*
|
|
||||||
* @param color the component color, or null to use the default
|
|
||||||
*/
|
|
||||||
public void setColor(ChatColor color)
|
|
||||||
{
|
|
||||||
this.style.setColor( color );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the color of this component. This uses the parent's color if this
|
* Returns the color of this component. This uses the parent's color if this
|
||||||
* component doesn't have one. {@link net.md_5.bungee.api.ChatColor#WHITE}
|
* component doesn't have one. {@link net.md_5.bungee.api.ChatColor#WHITE}
|
||||||
@ -270,7 +275,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public ChatColor getColor()
|
public ChatColor getColor()
|
||||||
{
|
{
|
||||||
if ( !style.hasColor() )
|
if ( color == null )
|
||||||
{
|
{
|
||||||
if ( parent == null )
|
if ( parent == null )
|
||||||
{
|
{
|
||||||
@ -278,7 +283,7 @@ public abstract class BaseComponent
|
|||||||
}
|
}
|
||||||
return parent.getColor();
|
return parent.getColor();
|
||||||
}
|
}
|
||||||
return style.getColor();
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -289,17 +294,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public ChatColor getColorRaw()
|
public ChatColor getColorRaw()
|
||||||
{
|
{
|
||||||
return style.getColor();
|
return color;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set this component's font.
|
|
||||||
*
|
|
||||||
* @param font the font to set, or null to use the default
|
|
||||||
*/
|
|
||||||
public void setFont(String font)
|
|
||||||
{
|
|
||||||
this.style.setFont( font );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -310,7 +305,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public String getFont()
|
public String getFont()
|
||||||
{
|
{
|
||||||
if ( !style.hasFont() )
|
if ( font == null )
|
||||||
{
|
{
|
||||||
if ( parent == null )
|
if ( parent == null )
|
||||||
{
|
{
|
||||||
@ -318,7 +313,7 @@ public abstract class BaseComponent
|
|||||||
}
|
}
|
||||||
return parent.getFont();
|
return parent.getFont();
|
||||||
}
|
}
|
||||||
return style.getFont();
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -329,17 +324,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public String getFontRaw()
|
public String getFontRaw()
|
||||||
{
|
{
|
||||||
return style.getFont();
|
return font;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether or not this component is bold.
|
|
||||||
*
|
|
||||||
* @param bold the new bold state, or null to use the default
|
|
||||||
*/
|
|
||||||
public void setBold(Boolean bold)
|
|
||||||
{
|
|
||||||
this.style.setBold( bold );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -351,11 +336,11 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public boolean isBold()
|
public boolean isBold()
|
||||||
{
|
{
|
||||||
if ( style.isBoldRaw() == null )
|
if ( bold == null )
|
||||||
{
|
{
|
||||||
return parent != null && parent.isBold();
|
return parent != null && parent.isBold();
|
||||||
}
|
}
|
||||||
return style.isBold();
|
return bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -366,17 +351,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public Boolean isBoldRaw()
|
public Boolean isBoldRaw()
|
||||||
{
|
{
|
||||||
return style.isBoldRaw();
|
return bold;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether or not this component is italic.
|
|
||||||
*
|
|
||||||
* @param italic the new italic state, or null to use the default
|
|
||||||
*/
|
|
||||||
public void setItalic(Boolean italic)
|
|
||||||
{
|
|
||||||
this.style.setItalic( italic );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -388,11 +363,11 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public boolean isItalic()
|
public boolean isItalic()
|
||||||
{
|
{
|
||||||
if ( style.isItalicRaw() == null )
|
if ( italic == null )
|
||||||
{
|
{
|
||||||
return parent != null && parent.isItalic();
|
return parent != null && parent.isItalic();
|
||||||
}
|
}
|
||||||
return style.isItalic();
|
return italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -403,17 +378,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public Boolean isItalicRaw()
|
public Boolean isItalicRaw()
|
||||||
{
|
{
|
||||||
return style.isItalicRaw();
|
return italic;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether or not this component is underlined.
|
|
||||||
*
|
|
||||||
* @param underlined the new underlined state, or null to use the default
|
|
||||||
*/
|
|
||||||
public void setUnderlined(Boolean underlined)
|
|
||||||
{
|
|
||||||
this.style.setUnderlined( underlined );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -425,11 +390,11 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public boolean isUnderlined()
|
public boolean isUnderlined()
|
||||||
{
|
{
|
||||||
if ( style.isUnderlinedRaw() == null )
|
if ( underlined == null )
|
||||||
{
|
{
|
||||||
return parent != null && parent.isUnderlined();
|
return parent != null && parent.isUnderlined();
|
||||||
}
|
}
|
||||||
return style.isUnderlined();
|
return underlined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -440,18 +405,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public Boolean isUnderlinedRaw()
|
public Boolean isUnderlinedRaw()
|
||||||
{
|
{
|
||||||
return style.isUnderlinedRaw();
|
return underlined;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether or not this component is strikethrough.
|
|
||||||
*
|
|
||||||
* @param strikethrough the new strikethrough state, or null to use the
|
|
||||||
* default
|
|
||||||
*/
|
|
||||||
public void setStrikethrough(Boolean strikethrough)
|
|
||||||
{
|
|
||||||
this.style.setStrikethrough( strikethrough );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -463,11 +417,11 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public boolean isStrikethrough()
|
public boolean isStrikethrough()
|
||||||
{
|
{
|
||||||
if ( style.isStrikethroughRaw() == null )
|
if ( strikethrough == null )
|
||||||
{
|
{
|
||||||
return parent != null && parent.isStrikethrough();
|
return parent != null && parent.isStrikethrough();
|
||||||
}
|
}
|
||||||
return style.isStrikethrough();
|
return strikethrough;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -478,17 +432,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public Boolean isStrikethroughRaw()
|
public Boolean isStrikethroughRaw()
|
||||||
{
|
{
|
||||||
return style.isStrikethroughRaw();
|
return strikethrough;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether or not this component is obfuscated.
|
|
||||||
*
|
|
||||||
* @param obfuscated the new obfuscated state, or null to use the default
|
|
||||||
*/
|
|
||||||
public void setObfuscated(Boolean obfuscated)
|
|
||||||
{
|
|
||||||
this.style.setObfuscated( obfuscated );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -500,11 +444,11 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public boolean isObfuscated()
|
public boolean isObfuscated()
|
||||||
{
|
{
|
||||||
if ( style.isObfuscatedRaw() == null )
|
if ( obfuscated == null )
|
||||||
{
|
{
|
||||||
return parent != null && parent.isObfuscated();
|
return parent != null && parent.isObfuscated();
|
||||||
}
|
}
|
||||||
return style.isObfuscated();
|
return obfuscated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -515,48 +459,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public Boolean isObfuscatedRaw()
|
public Boolean isObfuscatedRaw()
|
||||||
{
|
{
|
||||||
return style.isObfuscatedRaw();
|
return obfuscated;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply the style from the given {@link ComponentStyle} to this component.
|
|
||||||
* <p>
|
|
||||||
* Any style values that have been explicitly set in the style will be
|
|
||||||
* applied to this component. If a value is not set in the style, it will
|
|
||||||
* not override the style set in this component.
|
|
||||||
*
|
|
||||||
* @param style the style to apply
|
|
||||||
*/
|
|
||||||
public void applyStyle(ComponentStyle style)
|
|
||||||
{
|
|
||||||
if ( style.hasColor() )
|
|
||||||
{
|
|
||||||
setColor( style.getColor() );
|
|
||||||
}
|
|
||||||
if ( style.hasFont() )
|
|
||||||
{
|
|
||||||
setFont( style.getFont() );
|
|
||||||
}
|
|
||||||
if ( style.isBoldRaw() != null )
|
|
||||||
{
|
|
||||||
setBold( style.isBoldRaw() );
|
|
||||||
}
|
|
||||||
if ( style.isItalicRaw() != null )
|
|
||||||
{
|
|
||||||
setItalic( style.isItalicRaw() );
|
|
||||||
}
|
|
||||||
if ( style.isUnderlinedRaw() != null )
|
|
||||||
{
|
|
||||||
setUnderlined( style.isUnderlinedRaw() );
|
|
||||||
}
|
|
||||||
if ( style.isStrikethroughRaw() != null )
|
|
||||||
{
|
|
||||||
setStrikethrough( style.isStrikethroughRaw() );
|
|
||||||
}
|
|
||||||
if ( style.isObfuscatedRaw() != null )
|
|
||||||
{
|
|
||||||
setObfuscated( style.isObfuscatedRaw() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExtra(List<BaseComponent> components)
|
public void setExtra(List<BaseComponent> components)
|
||||||
@ -595,16 +498,6 @@ public abstract class BaseComponent
|
|||||||
extra.add( component );
|
extra.add( component );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the component has any styling applied to it.
|
|
||||||
*
|
|
||||||
* @return Whether any styling is applied
|
|
||||||
*/
|
|
||||||
public boolean hasStyle()
|
|
||||||
{
|
|
||||||
return !style.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the component has any formatting or events applied to it
|
* Returns whether the component has any formatting or events applied to it
|
||||||
*
|
*
|
||||||
@ -612,8 +505,10 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public boolean hasFormatting()
|
public boolean hasFormatting()
|
||||||
{
|
{
|
||||||
return hasStyle() || insertion != null
|
return color != null || font != null || bold != null
|
||||||
|| hoverEvent != null || clickEvent != null;
|
|| italic != null || underlined != null
|
||||||
|
|| strikethrough != null || obfuscated != null
|
||||||
|
|| insertion != null || hoverEvent != null || clickEvent != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -423,18 +423,6 @@ public final class ComponentBuilder
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies the provided {@link ComponentStyle} to the current part.
|
|
||||||
*
|
|
||||||
* @param style the style to apply
|
|
||||||
* @return this ComponentBuilder for chaining
|
|
||||||
*/
|
|
||||||
public ComponentBuilder style(ComponentStyle style)
|
|
||||||
{
|
|
||||||
getCurrentComponent().applyStyle( style );
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the insertion text for the current part.
|
* Sets the insertion text for the current part.
|
||||||
*
|
*
|
||||||
|
@ -1,234 +0,0 @@
|
|||||||
package net.md_5.bungee.api.chat;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a style that may be applied to a {@link BaseComponent}.
|
|
||||||
*/
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@EqualsAndHashCode
|
|
||||||
public final class ComponentStyle implements Cloneable
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The color of this style.
|
|
||||||
*/
|
|
||||||
private ChatColor color;
|
|
||||||
/**
|
|
||||||
* The font of this style.
|
|
||||||
*/
|
|
||||||
private String font;
|
|
||||||
/**
|
|
||||||
* Whether this style is bold.
|
|
||||||
*/
|
|
||||||
private Boolean bold;
|
|
||||||
/**
|
|
||||||
* Whether this style is italic.
|
|
||||||
*/
|
|
||||||
private Boolean italic;
|
|
||||||
/**
|
|
||||||
* Whether this style is underlined.
|
|
||||||
*/
|
|
||||||
private Boolean underlined;
|
|
||||||
/**
|
|
||||||
* Whether this style is strikethrough.
|
|
||||||
*/
|
|
||||||
private Boolean strikethrough;
|
|
||||||
/**
|
|
||||||
* Whether this style is obfuscated.
|
|
||||||
*/
|
|
||||||
private Boolean obfuscated;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the color of this style. May return null.
|
|
||||||
*
|
|
||||||
* @return the color of this style, or null if default color
|
|
||||||
*/
|
|
||||||
public ChatColor getColor()
|
|
||||||
{
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not this style has a color set.
|
|
||||||
*
|
|
||||||
* @return whether a color is set
|
|
||||||
*/
|
|
||||||
public boolean hasColor()
|
|
||||||
{
|
|
||||||
return ( color != null );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the font of this style. May return null.
|
|
||||||
*
|
|
||||||
* @return the font of this style, or null if default font
|
|
||||||
*/
|
|
||||||
public String getFont()
|
|
||||||
{
|
|
||||||
return font;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not this style has a font set.
|
|
||||||
*
|
|
||||||
* @return whether a font is set
|
|
||||||
*/
|
|
||||||
public boolean hasFont()
|
|
||||||
{
|
|
||||||
return ( font != null );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this style is bold.
|
|
||||||
*
|
|
||||||
* @return whether the style is bold
|
|
||||||
*/
|
|
||||||
public boolean isBold()
|
|
||||||
{
|
|
||||||
return ( bold != null ) && bold.booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this style is bold. May return null.
|
|
||||||
*
|
|
||||||
* @return whether the style is bold, or null if not set
|
|
||||||
*/
|
|
||||||
public Boolean isBoldRaw()
|
|
||||||
{
|
|
||||||
return bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this style is italic. May return null.
|
|
||||||
*
|
|
||||||
* @return whether the style is italic
|
|
||||||
*/
|
|
||||||
public boolean isItalic()
|
|
||||||
{
|
|
||||||
return ( italic != null ) && italic.booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this style is italic. May return null.
|
|
||||||
*
|
|
||||||
* @return whether the style is italic, or null if not set
|
|
||||||
*/
|
|
||||||
public Boolean isItalicRaw()
|
|
||||||
{
|
|
||||||
return italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this style is underlined.
|
|
||||||
*
|
|
||||||
* @return whether the style is underlined
|
|
||||||
*/
|
|
||||||
public boolean isUnderlined()
|
|
||||||
{
|
|
||||||
return ( underlined != null ) && underlined.booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this style is underlined. May return null.
|
|
||||||
*
|
|
||||||
* @return whether the style is underlined, or null if not set
|
|
||||||
*/
|
|
||||||
public Boolean isUnderlinedRaw()
|
|
||||||
{
|
|
||||||
return underlined;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this style is strikethrough
|
|
||||||
*
|
|
||||||
* @return whether the style is strikethrough
|
|
||||||
*/
|
|
||||||
public boolean isStrikethrough()
|
|
||||||
{
|
|
||||||
return ( strikethrough != null ) && strikethrough.booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this style is strikethrough. May return null.
|
|
||||||
*
|
|
||||||
* @return whether the style is strikethrough, or null if not set
|
|
||||||
*/
|
|
||||||
public Boolean isStrikethroughRaw()
|
|
||||||
{
|
|
||||||
return strikethrough;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this style is obfuscated.
|
|
||||||
*
|
|
||||||
* @return whether the style is obfuscated
|
|
||||||
*/
|
|
||||||
public boolean isObfuscated()
|
|
||||||
{
|
|
||||||
return ( obfuscated != null ) && obfuscated.booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this style is obfuscated. May return null.
|
|
||||||
*
|
|
||||||
* @return whether the style is obfuscated, or null if not set
|
|
||||||
*/
|
|
||||||
public Boolean isObfuscatedRaw()
|
|
||||||
{
|
|
||||||
return obfuscated;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this style has no formatting explicitly set.
|
|
||||||
*
|
|
||||||
* @return true if no value is set, false if at least one is set
|
|
||||||
*/
|
|
||||||
public boolean isEmpty()
|
|
||||||
{
|
|
||||||
return color == null && font == null && bold == null
|
|
||||||
&& italic == null && underlined == null
|
|
||||||
&& strikethrough == null && obfuscated == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ComponentStyle clone()
|
|
||||||
{
|
|
||||||
return new ComponentStyle( color, font, bold, italic, underlined, strikethrough, obfuscated );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a new {@link ComponentStyleBuilder}.
|
|
||||||
*
|
|
||||||
* @return the builder
|
|
||||||
*/
|
|
||||||
public static ComponentStyleBuilder builder()
|
|
||||||
{
|
|
||||||
return new ComponentStyleBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a new {@link ComponentStyleBuilder} with values initialized to the
|
|
||||||
* style values of the supplied {@link ComponentStyle}.
|
|
||||||
*
|
|
||||||
* @param other the component style whose values to copy into the builder
|
|
||||||
* @return the builder
|
|
||||||
*/
|
|
||||||
public static ComponentStyleBuilder builder(ComponentStyle other)
|
|
||||||
{
|
|
||||||
return new ComponentStyleBuilder()
|
|
||||||
.color( other.color )
|
|
||||||
.font( other.font )
|
|
||||||
.bold( other.bold )
|
|
||||||
.italic( other.italic )
|
|
||||||
.underlined( other.underlined )
|
|
||||||
.strikethrough( other.strikethrough )
|
|
||||||
.obfuscated( other.obfuscated );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
package net.md_5.bungee.api.chat;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* ComponentStyleBuilder simplifies creating component styles by allowing the
|
|
||||||
* use of a chainable builder.
|
|
||||||
* </p>
|
|
||||||
* <pre>
|
|
||||||
* ComponentStyle style = ComponentStyle.builder()
|
|
||||||
* .color(ChatColor.RED)
|
|
||||||
* .font("custom:font")
|
|
||||||
* .bold(true).italic(true).create();
|
|
||||||
*
|
|
||||||
* BaseComponent component = new ComponentBuilder("Hello world").style(style).create();
|
|
||||||
* // Or it can be used directly on a component
|
|
||||||
* TextComponent text = new TextComponent("Hello world");
|
|
||||||
* text.applyStyle(style);
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @see ComponentStyle#builder()
|
|
||||||
* @see ComponentStyle#builder(ComponentStyle)
|
|
||||||
*/
|
|
||||||
public final class ComponentStyleBuilder
|
|
||||||
{
|
|
||||||
|
|
||||||
private ChatColor color;
|
|
||||||
private String font;
|
|
||||||
private Boolean bold, italic, underlined, strikethrough, obfuscated;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the style color.
|
|
||||||
*
|
|
||||||
* @param color the color to set, or null to use the default
|
|
||||||
* @return this ComponentStyleBuilder for chaining
|
|
||||||
*/
|
|
||||||
public ComponentStyleBuilder color(ChatColor color)
|
|
||||||
{
|
|
||||||
this.color = color;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the style font.
|
|
||||||
*
|
|
||||||
* @param font the font key to set, or null to use the default
|
|
||||||
* @return this ComponentStyleBuilder for chaining
|
|
||||||
*/
|
|
||||||
public ComponentStyleBuilder font(String font)
|
|
||||||
{
|
|
||||||
this.font = font;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the style's bold property.
|
|
||||||
*
|
|
||||||
* @param bold the bold value to set, or null to use the default
|
|
||||||
* @return this ComponentStyleBuilder for chaining
|
|
||||||
*/
|
|
||||||
public ComponentStyleBuilder bold(Boolean bold)
|
|
||||||
{
|
|
||||||
this.bold = bold;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the style's italic property.
|
|
||||||
*
|
|
||||||
* @param italic the italic value to set, or null to use the default
|
|
||||||
* @return this ComponentStyleBuilder for chaining
|
|
||||||
*/
|
|
||||||
public ComponentStyleBuilder italic(Boolean italic)
|
|
||||||
{
|
|
||||||
this.italic = italic;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the style's underlined property.
|
|
||||||
*
|
|
||||||
* @param underlined the underlined value to set, or null to use the default
|
|
||||||
* @return this ComponentStyleBuilder for chaining
|
|
||||||
*/
|
|
||||||
public ComponentStyleBuilder underlined(Boolean underlined)
|
|
||||||
{
|
|
||||||
this.underlined = underlined;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the style's strikethrough property.
|
|
||||||
*
|
|
||||||
* @param strikethrough the strikethrough value to set, or null to use the
|
|
||||||
* default
|
|
||||||
* @return this ComponentStyleBuilder for chaining
|
|
||||||
*/
|
|
||||||
public ComponentStyleBuilder strikethrough(Boolean strikethrough)
|
|
||||||
{
|
|
||||||
this.strikethrough = strikethrough;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the style's obfuscated property.
|
|
||||||
*
|
|
||||||
* @param obfuscated the obfuscated value to set, or null to use the default
|
|
||||||
* @return this ComponentStyleBuilder for chaining
|
|
||||||
*/
|
|
||||||
public ComponentStyleBuilder obfuscated(Boolean obfuscated)
|
|
||||||
{
|
|
||||||
this.obfuscated = obfuscated;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build the {@link ComponentStyle} using the values set in this builder.
|
|
||||||
*
|
|
||||||
* @return the created ComponentStyle
|
|
||||||
*/
|
|
||||||
public ComponentStyle build()
|
|
||||||
{
|
|
||||||
return new ComponentStyle( color, font, bold, italic, underlined, strikethrough, obfuscated );
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,7 +8,6 @@ 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.UUID;
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
public class EntitySerializer implements JsonSerializer<Entity>, JsonDeserializer<Entity>
|
public class EntitySerializer implements JsonSerializer<Entity>, JsonDeserializer<Entity>
|
||||||
@ -19,19 +18,9 @@ public class EntitySerializer implements JsonSerializer<Entity>, JsonDeserialize
|
|||||||
{
|
{
|
||||||
JsonObject value = element.getAsJsonObject();
|
JsonObject value = element.getAsJsonObject();
|
||||||
|
|
||||||
String idString;
|
|
||||||
JsonElement id = value.get( "id" );
|
|
||||||
if ( id.isJsonArray() )
|
|
||||||
{
|
|
||||||
idString = parseUUID( context.deserialize( id, int[].class ) ).toString();
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
idString = id.getAsString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Entity(
|
return new Entity(
|
||||||
( value.has( "type" ) ) ? value.get( "type" ).getAsString() : null,
|
( value.has( "type" ) ) ? value.get( "type" ).getAsString() : null,
|
||||||
idString,
|
value.get( "id" ).getAsString(),
|
||||||
( value.has( "name" ) ) ? context.deserialize( value.get( "name" ), BaseComponent.class ) : null
|
( value.has( "name" ) ) ? context.deserialize( value.get( "name" ), BaseComponent.class ) : null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -48,9 +37,4 @@ public class EntitySerializer implements JsonSerializer<Entity>, JsonDeserialize
|
|||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UUID parseUUID(int[] array)
|
|
||||||
{
|
|
||||||
return new UUID( (long) array[0] << 32 | (long) array[1] & 0XFFFFFFFFL, (long) array[2] << 32 | (long) array[3] & 0XFFFFFFFFL );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,25 +4,73 @@ import com.google.common.base.Preconditions;
|
|||||||
import com.google.gson.JsonDeserializationContext;
|
import com.google.gson.JsonDeserializationContext;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.JsonPrimitive;
|
||||||
import com.google.gson.JsonSerializationContext;
|
import com.google.gson.JsonSerializationContext;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.ComponentStyle;
|
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.hover.content.Content;
|
import net.md_5.bungee.api.chat.hover.content.Content;
|
||||||
|
|
||||||
public class BaseComponentSerializer
|
public class BaseComponentSerializer
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static boolean getAsBoolean(JsonElement el)
|
||||||
|
{
|
||||||
|
if ( el.isJsonPrimitive() )
|
||||||
|
{
|
||||||
|
JsonPrimitive primitive = (JsonPrimitive) el;
|
||||||
|
|
||||||
|
if ( primitive.isBoolean() )
|
||||||
|
{
|
||||||
|
return primitive.getAsBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( primitive.isNumber() )
|
||||||
|
{
|
||||||
|
Number number = primitive.getAsNumber();
|
||||||
|
if ( number instanceof Byte )
|
||||||
|
{
|
||||||
|
return number.byteValue() != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected void deserialize(JsonObject object, BaseComponent component, JsonDeserializationContext context)
|
protected void deserialize(JsonObject object, BaseComponent component, JsonDeserializationContext context)
|
||||||
{
|
{
|
||||||
component.applyStyle( context.deserialize( object, ComponentStyle.class ) );
|
if ( object.has( "bold" ) )
|
||||||
|
{
|
||||||
|
component.setBold( getAsBoolean( object.get( "bold" ) ) );
|
||||||
|
}
|
||||||
|
if ( object.has( "italic" ) )
|
||||||
|
{
|
||||||
|
component.setItalic( getAsBoolean( object.get( "italic" ) ) );
|
||||||
|
}
|
||||||
|
if ( object.has( "underlined" ) )
|
||||||
|
{
|
||||||
|
component.setUnderlined( getAsBoolean( object.get( "underlined" ) ) );
|
||||||
|
}
|
||||||
|
if ( object.has( "strikethrough" ) )
|
||||||
|
{
|
||||||
|
component.setStrikethrough( getAsBoolean( object.get( "strikethrough" ) ) );
|
||||||
|
}
|
||||||
|
if ( object.has( "obfuscated" ) )
|
||||||
|
{
|
||||||
|
component.setObfuscated( getAsBoolean( object.get( "obfuscated" ) ) );
|
||||||
|
}
|
||||||
|
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() );
|
||||||
@ -42,48 +90,59 @@ public class BaseComponentSerializer
|
|||||||
HoverEvent hoverEvent = null;
|
HoverEvent hoverEvent = null;
|
||||||
HoverEvent.Action action = HoverEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase( Locale.ROOT ) );
|
HoverEvent.Action action = HoverEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase( Locale.ROOT ) );
|
||||||
|
|
||||||
if ( event.has( "value" ) )
|
for ( String type : Arrays.asList( "value", "contents" ) )
|
||||||
{
|
{
|
||||||
JsonElement contents = event.get( "value" );
|
if ( !event.has( type ) )
|
||||||
|
|
||||||
// Plugins previously had support to pass BaseComponent[] into any action.
|
|
||||||
// If the GSON is possible to be parsed as BaseComponent, attempt to parse as so.
|
|
||||||
BaseComponent[] components;
|
|
||||||
if ( contents.isJsonArray() )
|
|
||||||
{
|
{
|
||||||
components = context.deserialize( contents, BaseComponent[].class );
|
continue;
|
||||||
} else
|
|
||||||
{
|
|
||||||
components = new BaseComponent[]
|
|
||||||
{
|
|
||||||
context.deserialize( contents, BaseComponent.class )
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
hoverEvent = new HoverEvent( action, components );
|
JsonElement contents = event.get( type );
|
||||||
} else if ( event.has( "contents" ) )
|
try
|
||||||
{
|
{
|
||||||
JsonElement contents = event.get( "contents" );
|
|
||||||
|
|
||||||
Content[] list;
|
// Plugins previously had support to pass BaseComponent[] into any action.
|
||||||
if ( contents.isJsonArray() )
|
// If the GSON is possible to be parsed as BaseComponent, attempt to parse as so.
|
||||||
{
|
BaseComponent[] components;
|
||||||
list = context.deserialize( contents, HoverEvent.getClass( action, true ) );
|
if ( contents.isJsonArray() )
|
||||||
} else
|
|
||||||
{
|
|
||||||
list = new Content[]
|
|
||||||
{
|
{
|
||||||
context.deserialize( contents, HoverEvent.getClass( action, false ) )
|
components = context.deserialize( contents, BaseComponent[].class );
|
||||||
};
|
} else
|
||||||
|
{
|
||||||
|
components = new BaseComponent[]
|
||||||
|
{
|
||||||
|
context.deserialize( contents, BaseComponent.class )
|
||||||
|
};
|
||||||
|
}
|
||||||
|
hoverEvent = new HoverEvent( action, components );
|
||||||
|
} catch ( JsonParseException ex )
|
||||||
|
{
|
||||||
|
Content[] list;
|
||||||
|
if ( contents.isJsonArray() )
|
||||||
|
{
|
||||||
|
list = context.deserialize( contents, HoverEvent.getClass( action, true ) );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
list = new Content[]
|
||||||
|
{
|
||||||
|
context.deserialize( contents, HoverEvent.getClass( action, false ) )
|
||||||
|
};
|
||||||
|
}
|
||||||
|
hoverEvent = new HoverEvent( action, new ArrayList<>( Arrays.asList( list ) ) );
|
||||||
}
|
}
|
||||||
hoverEvent = new HoverEvent( action, new ArrayList<>( Arrays.asList( list ) ) );
|
|
||||||
|
// stop the loop as soon as either one is found
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hoverEvent != null )
|
if ( hoverEvent != null )
|
||||||
{
|
{
|
||||||
component.setHoverEvent( hoverEvent );
|
component.setHoverEvent( hoverEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( object.has( "font" ) )
|
||||||
|
{
|
||||||
|
component.setFont( object.get( "font" ).getAsString() );
|
||||||
|
}
|
||||||
if ( object.has( "extra" ) )
|
if ( object.has( "extra" ) )
|
||||||
{
|
{
|
||||||
component.setExtra( Arrays.asList( context.<BaseComponent[]>deserialize( object.get( "extra" ), BaseComponent[].class ) ) );
|
component.setExtra( Arrays.asList( context.<BaseComponent[]>deserialize( object.get( "extra" ), BaseComponent[].class ) ) );
|
||||||
@ -102,9 +161,30 @@ 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.isBoldRaw() != null )
|
||||||
ComponentStyleSerializer.serializeTo( component.getStyle(), object );
|
{
|
||||||
|
object.addProperty( "bold", component.isBoldRaw() );
|
||||||
|
}
|
||||||
|
if ( component.isItalicRaw() != null )
|
||||||
|
{
|
||||||
|
object.addProperty( "italic", component.isItalicRaw() );
|
||||||
|
}
|
||||||
|
if ( component.isUnderlinedRaw() != null )
|
||||||
|
{
|
||||||
|
object.addProperty( "underlined", component.isUnderlinedRaw() );
|
||||||
|
}
|
||||||
|
if ( component.isStrikethroughRaw() != null )
|
||||||
|
{
|
||||||
|
object.addProperty( "strikethrough", component.isStrikethroughRaw() );
|
||||||
|
}
|
||||||
|
if ( component.isObfuscatedRaw() != null )
|
||||||
|
{
|
||||||
|
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() );
|
||||||
@ -133,6 +213,10 @@ public class BaseComponentSerializer
|
|||||||
object.add( "hoverEvent", hoverEvent );
|
object.add( "hoverEvent", hoverEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( component.getFontRaw() != null )
|
||||||
|
{
|
||||||
|
object.addProperty( "font", component.getFontRaw() );
|
||||||
|
}
|
||||||
if ( component.getExtra() != null )
|
if ( component.getExtra() != null )
|
||||||
{
|
{
|
||||||
object.add( "extra", context.serialize( component.getExtra() ) );
|
object.add( "extra", context.serialize( component.getExtra() ) );
|
||||||
|
@ -13,7 +13,6 @@ import com.google.gson.JsonPrimitive;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.ComponentStyle;
|
|
||||||
import net.md_5.bungee.api.chat.ItemTag;
|
import net.md_5.bungee.api.chat.ItemTag;
|
||||||
import net.md_5.bungee.api.chat.KeybindComponent;
|
import net.md_5.bungee.api.chat.KeybindComponent;
|
||||||
import net.md_5.bungee.api.chat.ScoreComponent;
|
import net.md_5.bungee.api.chat.ScoreComponent;
|
||||||
@ -37,7 +36,6 @@ public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
|||||||
registerTypeAdapter( KeybindComponent.class, new KeybindComponentSerializer() ).
|
registerTypeAdapter( KeybindComponent.class, new KeybindComponentSerializer() ).
|
||||||
registerTypeAdapter( ScoreComponent.class, new ScoreComponentSerializer() ).
|
registerTypeAdapter( ScoreComponent.class, new ScoreComponentSerializer() ).
|
||||||
registerTypeAdapter( SelectorComponent.class, new SelectorComponentSerializer() ).
|
registerTypeAdapter( SelectorComponent.class, new SelectorComponentSerializer() ).
|
||||||
registerTypeAdapter( ComponentStyle.class, new ComponentStyleSerializer() ).
|
|
||||||
registerTypeAdapter( Entity.class, new EntitySerializer() ).
|
registerTypeAdapter( Entity.class, new EntitySerializer() ).
|
||||||
registerTypeAdapter( Text.class, new TextSerializer() ).
|
registerTypeAdapter( Text.class, new TextSerializer() ).
|
||||||
registerTypeAdapter( Item.class, new ItemSerializer() ).
|
registerTypeAdapter( Item.class, new ItemSerializer() ).
|
||||||
@ -120,44 +118,11 @@ public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
|||||||
return gson.fromJson( jsonElement, BaseComponent.class );
|
return gson.fromJson( jsonElement, BaseComponent.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserialize a JSON-compliant String as a component style.
|
|
||||||
*
|
|
||||||
* @param json the component style json to parse
|
|
||||||
* @return the deserialized component style
|
|
||||||
* @throws IllegalArgumentException if anything other than a valid JSON
|
|
||||||
* component style string is passed as input
|
|
||||||
*/
|
|
||||||
public static ComponentStyle deserializeStyle(String json)
|
|
||||||
{
|
|
||||||
JsonElement jsonElement = JsonParser.parseString( json );
|
|
||||||
|
|
||||||
return deserializeStyle( jsonElement );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserialize a JSON element as a component style.
|
|
||||||
*
|
|
||||||
* @param jsonElement the component style json to parse
|
|
||||||
* @return the deserialized component style
|
|
||||||
* @throws IllegalArgumentException if anything other than a valid JSON
|
|
||||||
* component style is passed as input
|
|
||||||
*/
|
|
||||||
public static ComponentStyle deserializeStyle(JsonElement jsonElement)
|
|
||||||
{
|
|
||||||
return gson.fromJson( jsonElement, ComponentStyle.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JsonElement toJson(BaseComponent component)
|
public static JsonElement toJson(BaseComponent component)
|
||||||
{
|
{
|
||||||
return gson.toJsonTree( component );
|
return gson.toJsonTree( component );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JsonElement toJson(ComponentStyle style)
|
|
||||||
{
|
|
||||||
return gson.toJsonTree( style );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toString(Object object)
|
public static String toString(Object object)
|
||||||
{
|
{
|
||||||
return gson.toJson( object );
|
return gson.toJson( object );
|
||||||
@ -179,11 +144,6 @@ public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toString(ComponentStyle style)
|
|
||||||
{
|
|
||||||
return gson.toJson( style );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
public BaseComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||||
{
|
{
|
||||||
|
@ -1,118 +0,0 @@
|
|||||||
package net.md_5.bungee.chat;
|
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonPrimitive;
|
|
||||||
import com.google.gson.JsonSerializationContext;
|
|
||||||
import com.google.gson.JsonSerializer;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.chat.ComponentStyle;
|
|
||||||
import net.md_5.bungee.api.chat.ComponentStyleBuilder;
|
|
||||||
|
|
||||||
public class ComponentStyleSerializer implements JsonSerializer<ComponentStyle>, JsonDeserializer<ComponentStyle>
|
|
||||||
{
|
|
||||||
|
|
||||||
private static boolean getAsBoolean(JsonElement el)
|
|
||||||
{
|
|
||||||
if ( el.isJsonPrimitive() )
|
|
||||||
{
|
|
||||||
JsonPrimitive primitive = (JsonPrimitive) el;
|
|
||||||
|
|
||||||
if ( primitive.isBoolean() )
|
|
||||||
{
|
|
||||||
return primitive.getAsBoolean();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( primitive.isNumber() )
|
|
||||||
{
|
|
||||||
Number number = primitive.getAsNumber();
|
|
||||||
if ( number instanceof Byte )
|
|
||||||
{
|
|
||||||
return number.byteValue() != 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void serializeTo(ComponentStyle style, JsonObject object)
|
|
||||||
{
|
|
||||||
if ( style.isBoldRaw() != null )
|
|
||||||
{
|
|
||||||
object.addProperty( "bold", style.isBoldRaw() );
|
|
||||||
}
|
|
||||||
if ( style.isItalicRaw() != null )
|
|
||||||
{
|
|
||||||
object.addProperty( "italic", style.isItalicRaw() );
|
|
||||||
}
|
|
||||||
if ( style.isUnderlinedRaw() != null )
|
|
||||||
{
|
|
||||||
object.addProperty( "underlined", style.isUnderlinedRaw() );
|
|
||||||
}
|
|
||||||
if ( style.isStrikethroughRaw() != null )
|
|
||||||
{
|
|
||||||
object.addProperty( "strikethrough", style.isStrikethroughRaw() );
|
|
||||||
}
|
|
||||||
if ( style.isObfuscatedRaw() != null )
|
|
||||||
{
|
|
||||||
object.addProperty( "obfuscated", style.isObfuscatedRaw() );
|
|
||||||
}
|
|
||||||
if ( style.hasColor() )
|
|
||||||
{
|
|
||||||
object.addProperty( "color", style.getColor().getName() );
|
|
||||||
}
|
|
||||||
if ( style.hasFont() )
|
|
||||||
{
|
|
||||||
object.addProperty( "font", style.getFont() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ComponentStyle deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
|
||||||
{
|
|
||||||
ComponentStyleBuilder builder = ComponentStyle.builder();
|
|
||||||
JsonObject object = json.getAsJsonObject();
|
|
||||||
if ( object.has( "bold" ) )
|
|
||||||
{
|
|
||||||
builder.bold( getAsBoolean( object.get( "bold" ) ) );
|
|
||||||
}
|
|
||||||
if ( object.has( "italic" ) )
|
|
||||||
{
|
|
||||||
builder.italic( getAsBoolean( object.get( "italic" ) ) );
|
|
||||||
}
|
|
||||||
if ( object.has( "underlined" ) )
|
|
||||||
{
|
|
||||||
builder.underlined( getAsBoolean( object.get( "underlined" ) ) );
|
|
||||||
}
|
|
||||||
if ( object.has( "strikethrough" ) )
|
|
||||||
{
|
|
||||||
builder.strikethrough( getAsBoolean( object.get( "strikethrough" ) ) );
|
|
||||||
}
|
|
||||||
if ( object.has( "obfuscated" ) )
|
|
||||||
{
|
|
||||||
builder.obfuscated( getAsBoolean( object.get( "obfuscated" ) ) );
|
|
||||||
}
|
|
||||||
if ( object.has( "color" ) )
|
|
||||||
{
|
|
||||||
builder.color( ChatColor.of( object.get( "color" ).getAsString() ) );
|
|
||||||
}
|
|
||||||
if ( object.has( "font" ) )
|
|
||||||
{
|
|
||||||
builder.font( object.get( "font" ).getAsString() );
|
|
||||||
}
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize(ComponentStyle src, Type typeOfSrc, JsonSerializationContext context)
|
|
||||||
{
|
|
||||||
JsonObject object = new JsonObject();
|
|
||||||
serializeTo( src, object );
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,7 +8,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.ObjIntConsumer;
|
import java.util.function.ObjIntConsumer;
|
||||||
import java.util.function.Supplier;
|
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.Entity;
|
|
||||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -89,14 +88,6 @@ public class ComponentsTest
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testArrayUUIDParse()
|
|
||||||
{
|
|
||||||
BaseComponent[] uuidComponent = ComponentSerializer.parse( "{\"translate\":\"multiplayer.player.joined\",\"with\":[{\"text\":\"Rexcantor64\",\"hoverEvent\":{\"contents\":{\"type\":\"minecraft:player\",\"id\":[1328556382,-2138814985,-1895806765,-1039963041],\"name\":\"Rexcantor64\"},\"action\":\"show_entity\"},\"insertion\":\"Rexcantor64\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/tell Rexcantor64 \"}}],\"color\":\"yellow\"}" );
|
|
||||||
assertEquals( "4f30295e-8084-45f7-8f00-48d3c2036c5f", ( (Entity) ( (TranslatableComponent) uuidComponent[0] ).getWith().get( 0 ).getHoverEvent().getContents().get( 0 ) ).getId() );
|
|
||||||
testDissembleReassemble( uuidComponent );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyComponentBuilderCreate()
|
public void testEmptyComponentBuilderCreate()
|
||||||
{
|
{
|
||||||
@ -430,16 +421,6 @@ public class ComponentsTest
|
|||||||
assertArrayEquals( component, reparsed );
|
assertArrayEquals( component, reparsed );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStyle()
|
|
||||||
{
|
|
||||||
ComponentStyle style = ComponentSerializer.deserializeStyle( "{\"color\":\"red\",\"font\":\"minecraft:example\",\"bold\":true,\"italic\":false,\"obfuscated\":true}" );
|
|
||||||
String text = ComponentSerializer.toString( style );
|
|
||||||
ComponentStyle reparsed = ComponentSerializer.deserializeStyle( text );
|
|
||||||
|
|
||||||
assertEquals( style, reparsed );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendCreate()
|
public void testBuilderAppendCreate()
|
||||||
{
|
{
|
||||||
@ -825,28 +806,6 @@ public class ComponentsTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testHasFormatting()
|
|
||||||
{
|
|
||||||
BaseComponent component = new TextComponent();
|
|
||||||
assertFalse( component.hasFormatting() );
|
|
||||||
|
|
||||||
component.setBold( true );
|
|
||||||
assertTrue( component.hasFormatting() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStyleIsEmpty()
|
|
||||||
{
|
|
||||||
ComponentStyle style = ComponentStyle.builder().build();
|
|
||||||
assertTrue( style.isEmpty() );
|
|
||||||
|
|
||||||
style = ComponentStyle.builder()
|
|
||||||
.bold( true )
|
|
||||||
.build();
|
|
||||||
assertFalse( style.isEmpty() );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In legacy chat, colors and reset both reset all formatting.
|
* In legacy chat, colors and reset both reset all formatting.
|
||||||
* Make sure it works in combination with ComponentBuilder.
|
* Make sure it works in combination with ComponentBuilder.
|
||||||
|
@ -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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Config</name>
|
<name>BungeeCord-Config</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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Event</name>
|
<name>BungeeCord-Event</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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Log</name>
|
<name>BungeeCord-Log</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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_alert</name>
|
<name>cmd_alert</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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_find</name>
|
<name>cmd_find</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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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-kick</artifactId>
|
<artifactId>bungeecord-module-cmd-kick</artifactId>
|
||||||
<version>1.20-R0.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_kick</name>
|
<name>cmd_kick</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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_list</name>
|
<name>cmd_list</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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>BungeeCord Modules</name>
|
<name>BungeeCord Modules</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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>reconnect_yaml</name>
|
<name>reconnect_yaml</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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Native</name>
|
<name>BungeeCord-Native</name>
|
||||||
|
16
pom.xml
16
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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Parent</name>
|
<name>BungeeCord-Parent</name>
|
||||||
@ -83,7 +83,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-bom</artifactId>
|
<artifactId>netty-bom</artifactId>
|
||||||
<version>4.1.107.Final</version>
|
<version>4.1.100.Final</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -93,7 +93,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
<version>5.10.2</version>
|
<version>5.10.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -108,12 +108,6 @@
|
|||||||
<version>3.0.1</version>
|
<version>3.0.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains</groupId>
|
|
||||||
<artifactId>annotations-java5</artifactId>
|
|
||||||
<version>24.1.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
@ -128,7 +122,7 @@
|
|||||||
<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.6.3</version>
|
<version>3.6.2</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
@ -152,7 +146,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.12.1</version>
|
<version>3.11.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
@ -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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Protocol</name>
|
<name>BungeeCord-Protocol</name>
|
||||||
|
@ -8,8 +8,6 @@ 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.CookieRequest;
|
|
||||||
import net.md_5.bungee.protocol.packet.CookieResponse;
|
|
||||||
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;
|
||||||
@ -42,7 +40,6 @@ import net.md_5.bungee.protocol.packet.SetCompression;
|
|||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
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.StoreCookie;
|
|
||||||
import net.md_5.bungee.protocol.packet.Subtitle;
|
import net.md_5.bungee.protocol.packet.Subtitle;
|
||||||
import net.md_5.bungee.protocol.packet.SystemChat;
|
import net.md_5.bungee.protocol.packet.SystemChat;
|
||||||
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||||
@ -50,7 +47,6 @@ 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.TitleTimes;
|
||||||
import net.md_5.bungee.protocol.packet.Transfer;
|
|
||||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||||
|
|
||||||
public abstract class AbstractPacketHandler
|
public abstract class AbstractPacketHandler
|
||||||
@ -247,20 +243,4 @@ public abstract class AbstractPacketHandler
|
|||||||
public void handle(FinishConfiguration finishConfiguration) throws Exception
|
public void handle(FinishConfiguration finishConfiguration) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(Transfer transfer) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(StoreCookie storeCookie) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(CookieRequest cookieRequest) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(CookieResponse cookieResponse) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ import java.util.UUID;
|
|||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.ComponentStyle;
|
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
import se.llbit.nbt.ErrorTag;
|
import se.llbit.nbt.ErrorTag;
|
||||||
import se.llbit.nbt.NamedTag;
|
import se.llbit.nbt.NamedTag;
|
||||||
@ -119,14 +118,6 @@ public abstract class DefinedPacket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ComponentStyle readComponentStyle(ByteBuf buf, int protocolVersion)
|
|
||||||
{
|
|
||||||
SpecificTag nbt = (SpecificTag) readTag( buf, protocolVersion );
|
|
||||||
JsonElement json = TagUtil.toJson( nbt );
|
|
||||||
|
|
||||||
return ComponentSerializer.deserializeStyle( json );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeEitherBaseComponent(Either<String, BaseComponent> message, ByteBuf buf, int protocolVersion)
|
public static void writeEitherBaseComponent(Either<String, BaseComponent> message, ByteBuf buf, int protocolVersion)
|
||||||
{
|
{
|
||||||
if ( message.isLeft() )
|
if ( message.isLeft() )
|
||||||
@ -154,14 +145,6 @@ public abstract class DefinedPacket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeComponentStyle(ComponentStyle style, ByteBuf buf, int protocolVersion)
|
|
||||||
{
|
|
||||||
JsonElement json = ComponentSerializer.toJson( style );
|
|
||||||
SpecificTag nbt = TagUtil.fromJson( json );
|
|
||||||
|
|
||||||
writeTag( nbt, buf, protocolVersion );
|
|
||||||
}
|
|
||||||
|
|
||||||
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 )
|
||||||
@ -248,7 +231,7 @@ public abstract class DefinedPacket
|
|||||||
|
|
||||||
if ( bytes > maxBytes )
|
if ( bytes > maxBytes )
|
||||||
{
|
{
|
||||||
throw new OverflowPacketException( "VarInt too big (max " + maxBytes + ")" );
|
throw new RuntimeException( "VarInt too big" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( in & 0x80 ) != 0x80 )
|
if ( ( in & 0x80 ) != 0x80 )
|
||||||
@ -395,7 +378,7 @@ public abstract class DefinedPacket
|
|||||||
case BLANK:
|
case BLANK:
|
||||||
break;
|
break;
|
||||||
case STYLED:
|
case STYLED:
|
||||||
writeComponentStyle( (ComponentStyle) format.getValue(), buf, protocolVersion );
|
writeBaseComponent( (BaseComponent) format.getValue(), buf, protocolVersion ); // TODO: style
|
||||||
break;
|
break;
|
||||||
case FIXED:
|
case FIXED:
|
||||||
writeBaseComponent( (BaseComponent) format.getValue(), buf, protocolVersion );
|
writeBaseComponent( (BaseComponent) format.getValue(), buf, protocolVersion );
|
||||||
@ -411,7 +394,7 @@ public abstract class DefinedPacket
|
|||||||
case 0:
|
case 0:
|
||||||
return new NumberFormat( NumberFormat.Type.BLANK, null );
|
return new NumberFormat( NumberFormat.Type.BLANK, null );
|
||||||
case 1:
|
case 1:
|
||||||
return new NumberFormat( NumberFormat.Type.STYLED, readComponentStyle( buf, protocolVersion ) );
|
return new NumberFormat( NumberFormat.Type.STYLED, readBaseComponent( buf, protocolVersion ) ); // TODO: style
|
||||||
case 2:
|
case 2:
|
||||||
return new NumberFormat( NumberFormat.Type.FIXED, readBaseComponent( buf, protocolVersion ) );
|
return new NumberFormat( NumberFormat.Type.FIXED, readBaseComponent( buf, protocolVersion ) );
|
||||||
default:
|
default:
|
||||||
|
@ -16,8 +16,6 @@ import net.md_5.bungee.protocol.packet.ClientChat;
|
|||||||
import net.md_5.bungee.protocol.packet.ClientCommand;
|
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.CookieRequest;
|
|
||||||
import net.md_5.bungee.protocol.packet.CookieResponse;
|
|
||||||
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;
|
||||||
@ -48,7 +46,6 @@ import net.md_5.bungee.protocol.packet.SetCompression;
|
|||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
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.StoreCookie;
|
|
||||||
import net.md_5.bungee.protocol.packet.Subtitle;
|
import net.md_5.bungee.protocol.packet.Subtitle;
|
||||||
import net.md_5.bungee.protocol.packet.SystemChat;
|
import net.md_5.bungee.protocol.packet.SystemChat;
|
||||||
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||||
@ -56,7 +53,6 @@ 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.TitleTimes;
|
||||||
import net.md_5.bungee.protocol.packet.Transfer;
|
|
||||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||||
|
|
||||||
public enum Protocol
|
public enum Protocol
|
||||||
@ -94,8 +90,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x20 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x20 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x1F ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x1F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x23 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x23 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x24 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x24 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x26 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Login.class,
|
Login.class,
|
||||||
@ -111,8 +106,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x25 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x25 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x24 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x24 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x28 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x28 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x29 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x29 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x2B )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket( Chat.class,
|
TO_CLIENT.registerPacket( Chat.class,
|
||||||
Chat::new,
|
Chat::new,
|
||||||
@ -142,8 +136,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x3D ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x3D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x41 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x41 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x43 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x43 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x45 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x45 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x47 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
BossBar.class,
|
BossBar.class,
|
||||||
@ -202,8 +195,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x54 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x54 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x58 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x58 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5A ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5C ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5C )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x5E )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ScoreboardScore.class,
|
ScoreboardScore.class,
|
||||||
@ -220,14 +212,12 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x57 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x57 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5B ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5D ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5F ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5F )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x61 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ScoreboardScoreReset.class,
|
ScoreboardScoreReset.class,
|
||||||
ScoreboardScoreReset::new,
|
ScoreboardScoreReset::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x42 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x42 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x44 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ScoreboardDisplay.class,
|
ScoreboardDisplay.class,
|
||||||
@ -244,8 +234,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4D ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x51 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x51 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x53 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x53 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x55 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x55 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x57 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Team.class,
|
Team.class,
|
||||||
@ -262,8 +251,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x56 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x56 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5A ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5C ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5E ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5E )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x60 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PluginMessage.class,
|
PluginMessage.class,
|
||||||
@ -280,8 +268,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x16 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x16 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x15 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x15 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x17 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x17 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x18 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x18 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x19 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Kick.class,
|
Kick.class,
|
||||||
@ -298,8 +285,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x19 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x19 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x17 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x17 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x1A ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x1A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x1B ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x1B )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x1D )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Title.class,
|
Title.class,
|
||||||
@ -317,8 +303,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5B ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5F ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x61 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x61 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x63 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x63 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x65 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ClearTitles.class,
|
ClearTitles.class,
|
||||||
@ -338,8 +323,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x59 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x59 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5D ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5F ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x61 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x61 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x63 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
TitleTimes.class,
|
TitleTimes.class,
|
||||||
@ -350,8 +334,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5C ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x60 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x60 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x62 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x62 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x64 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x64 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x66 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
SystemChat.class,
|
SystemChat.class,
|
||||||
@ -361,8 +344,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x60 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x60 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x64 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x64 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x67 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x67 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x69 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x69 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x6C )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PlayerListHeaderFooter.class,
|
PlayerListHeaderFooter.class,
|
||||||
@ -383,8 +365,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x61 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x61 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x65 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x65 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x68 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x68 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x6A ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x6A )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x6D )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
EntityStatus.class,
|
EntityStatus.class,
|
||||||
@ -401,8 +382,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x1A ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x1A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x19 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x19 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x1C ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x1C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x1D ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x1D )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x1F )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Commands.class,
|
Commands.class,
|
||||||
@ -428,8 +408,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x1D ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x1D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x1C ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x1C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x1F ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x1F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x20 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x20 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x22 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ViewDistance.class,
|
ViewDistance.class,
|
||||||
@ -443,8 +422,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4B ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x4F ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x4F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x51 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x51 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x53 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x53 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x62 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ServerData.class,
|
ServerData.class,
|
||||||
@ -454,46 +432,27 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x41 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x41 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x45 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x45 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x47 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x47 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x49 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x49 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x4B )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PlayerListItemRemove.class,
|
PlayerListItemRemove.class,
|
||||||
PlayerListItemRemove::new,
|
PlayerListItemRemove::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x35 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x35 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x39 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x39 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x3B ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x3B )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x3D )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PlayerListItemUpdate.class,
|
PlayerListItemUpdate.class,
|
||||||
PlayerListItemUpdate::new,
|
PlayerListItemUpdate::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x36 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x36 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x3A ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x3A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x3C ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x3C )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x3E )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
StartConfiguration.class,
|
StartConfiguration.class,
|
||||||
StartConfiguration::new,
|
StartConfiguration::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x65 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x65 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x67 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x67 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x69 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
CookieRequest.class,
|
|
||||||
CookieRequest::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x16 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
StoreCookie.class,
|
|
||||||
StoreCookie::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x6B )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
Transfer.class,
|
|
||||||
Transfer::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x73 )
|
|
||||||
);
|
);
|
||||||
|
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
@ -512,8 +471,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x11 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x11 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x12 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x12 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x14 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x14 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x15 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x15 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x17 )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket( Chat.class,
|
TO_SERVER.registerPacket( Chat.class,
|
||||||
Chat::new,
|
Chat::new,
|
||||||
@ -580,19 +538,13 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0C ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0D ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x10 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x10 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x11 )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
StartConfiguration.class,
|
StartConfiguration.class,
|
||||||
StartConfiguration::new,
|
StartConfiguration::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0B )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0B )
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
CookieResponse.class,
|
|
||||||
CookieResponse::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x10 )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 1
|
// 1
|
||||||
@ -653,11 +605,6 @@ public enum Protocol
|
|||||||
LoginPayloadRequest::new,
|
LoginPayloadRequest::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x04 )
|
map( ProtocolConstants.MINECRAFT_1_13, 0x04 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
CookieRequest.class,
|
|
||||||
CookieRequest::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x05 )
|
|
||||||
);
|
|
||||||
|
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
LoginRequest.class,
|
LoginRequest.class,
|
||||||
@ -679,11 +626,6 @@ public enum Protocol
|
|||||||
LoginAcknowledged::new,
|
LoginAcknowledged::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 )
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
CookieResponse.class,
|
|
||||||
CookieResponse::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x04 )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 3
|
// 3
|
||||||
@ -691,45 +633,25 @@ public enum Protocol
|
|||||||
{
|
{
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
CookieRequest.class,
|
|
||||||
CookieRequest::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x00 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PluginMessage.class,
|
PluginMessage.class,
|
||||||
PluginMessage::new,
|
PluginMessage::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x00 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x00 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x01 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Kick.class,
|
Kick.class,
|
||||||
Kick::new,
|
Kick::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x02 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
FinishConfiguration.class,
|
FinishConfiguration.class,
|
||||||
FinishConfiguration::new,
|
FinishConfiguration::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x03 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
KeepAlive.class,
|
KeepAlive.class,
|
||||||
KeepAlive::new,
|
KeepAlive::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x04 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
StoreCookie.class,
|
|
||||||
StoreCookie::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x09 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
Transfer.class,
|
|
||||||
Transfer::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0A )
|
|
||||||
);
|
);
|
||||||
|
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
@ -740,20 +662,17 @@ public enum Protocol
|
|||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
PluginMessage.class,
|
PluginMessage.class,
|
||||||
PluginMessage::new,
|
PluginMessage::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x02 )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
FinishConfiguration.class,
|
FinishConfiguration.class,
|
||||||
FinishConfiguration::new,
|
FinishConfiguration::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x03 )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
KeepAlive.class,
|
KeepAlive.class,
|
||||||
KeepAlive::new,
|
KeepAlive::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x04 )
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -45,7 +45,6 @@ public class ProtocolConstants
|
|||||||
public static final int MINECRAFT_1_20 = 763;
|
public static final int MINECRAFT_1_20 = 763;
|
||||||
public static final int MINECRAFT_1_20_2 = 764;
|
public static final int MINECRAFT_1_20_2 = 764;
|
||||||
public static final int MINECRAFT_1_20_3 = 765;
|
public static final int MINECRAFT_1_20_3 = 765;
|
||||||
public static final int MINECRAFT_1_20_5 = 1073742000;
|
|
||||||
public static final List<String> SUPPORTED_VERSIONS;
|
public static final List<String> SUPPORTED_VERSIONS;
|
||||||
public static final List<Integer> SUPPORTED_VERSION_IDS;
|
public static final List<Integer> SUPPORTED_VERSION_IDS;
|
||||||
|
|
||||||
@ -110,7 +109,7 @@ public class ProtocolConstants
|
|||||||
if ( SNAPSHOT_SUPPORT )
|
if ( SNAPSHOT_SUPPORT )
|
||||||
{
|
{
|
||||||
// supportedVersions.add( "1.20.x" );
|
// supportedVersions.add( "1.20.x" );
|
||||||
supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20_5 );
|
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20_3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
SUPPORTED_VERSIONS = supportedVersions.build();
|
SUPPORTED_VERSIONS = supportedVersions.build();
|
||||||
|
@ -124,11 +124,9 @@ public final class TagUtil
|
|||||||
for ( JsonElement jsonEl : jsonArray )
|
for ( JsonElement jsonEl : jsonArray )
|
||||||
{
|
{
|
||||||
SpecificTag subTag = fromJson( jsonEl );
|
SpecificTag subTag = fromJson( jsonEl );
|
||||||
if ( !( subTag instanceof CompoundTag ) )
|
if ( subTag.tagType() != listType )
|
||||||
{
|
{
|
||||||
CompoundTag wrapper = new CompoundTag();
|
throw new IllegalArgumentException( "Cannot convert mixed JsonArray to Tag" );
|
||||||
wrapper.add( "", subTag );
|
|
||||||
subTag = wrapper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tagItems.add( subTag );
|
tagItems.add( subTag );
|
||||||
@ -181,20 +179,6 @@ public final class TagUtil
|
|||||||
JsonArray jsonList = new JsonArray( items.size() );
|
JsonArray jsonList = new JsonArray( items.size() );
|
||||||
for ( SpecificTag subTag : items )
|
for ( SpecificTag subTag : items )
|
||||||
{
|
{
|
||||||
if ( subTag instanceof CompoundTag )
|
|
||||||
{
|
|
||||||
CompoundTag compound = (CompoundTag) subTag;
|
|
||||||
if ( compound.size() == 1 )
|
|
||||||
{
|
|
||||||
SpecificTag first = (SpecificTag) compound.get( "" );
|
|
||||||
if ( !first.isError() )
|
|
||||||
{
|
|
||||||
jsonList.add( toJson( first ) );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonList.add( toJson( subTag ) );
|
jsonList.add( toJson( subTag ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 CookieRequest extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private String cookie;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
cookie = readString( buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
writeString( cookie, buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +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 CookieResponse extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private String cookie;
|
|
||||||
private byte[] data;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
cookie = readString( buf );
|
|
||||||
data = readNullable( DefinedPacket::readArray, buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
writeString( cookie, buf );
|
|
||||||
writeNullable( data, DefinedPacket::writeArray, buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,7 +19,6 @@ public class EncryptionRequest extends DefinedPacket
|
|||||||
private String serverId;
|
private String serverId;
|
||||||
private byte[] publicKey;
|
private byte[] publicKey;
|
||||||
private byte[] verifyToken;
|
private byte[] verifyToken;
|
||||||
private boolean shouldAuthenticate;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
@ -27,10 +26,6 @@ public class EncryptionRequest extends DefinedPacket
|
|||||||
serverId = readString( buf );
|
serverId = readString( buf );
|
||||||
publicKey = readArray( buf );
|
publicKey = readArray( buf );
|
||||||
verifyToken = readArray( buf );
|
verifyToken = readArray( buf );
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
|
|
||||||
{
|
|
||||||
shouldAuthenticate = buf.readBoolean();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -39,10 +34,6 @@ public class EncryptionRequest extends DefinedPacket
|
|||||||
writeString( serverId, buf );
|
writeString( serverId, buf );
|
||||||
writeArray( publicKey, buf );
|
writeArray( publicKey, buf );
|
||||||
writeArray( verifyToken, buf );
|
writeArray( verifyToken, buf );
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( shouldAuthenticate );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,7 +41,6 @@ public class Login extends DefinedPacket
|
|||||||
private boolean flat;
|
private boolean flat;
|
||||||
private Location deathLocation;
|
private Location deathLocation;
|
||||||
private int portalCooldown;
|
private int portalCooldown;
|
||||||
private boolean secureProfile;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
@ -155,11 +154,6 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
portalCooldown = readVarInt( buf );
|
portalCooldown = readVarInt( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
|
|
||||||
{
|
|
||||||
secureProfile = buf.readBoolean();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -281,11 +275,6 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
writeVarInt( portalCooldown, buf );
|
writeVarInt( portalCooldown, buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( secureProfile );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,7 +33,7 @@ public class ServerData extends DefinedPacket
|
|||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_4 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_4 )
|
||||||
{
|
{
|
||||||
icon = readArray( buf );
|
icon = DefinedPacket.readArray( buf );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
icon = readString( buf );
|
icon = readString( buf );
|
||||||
@ -45,7 +45,7 @@ public class ServerData extends DefinedPacket
|
|||||||
preview = buf.readBoolean();
|
preview = buf.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 && protocolVersion < ProtocolConstants.MINECRAFT_1_20_5 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
||||||
{
|
{
|
||||||
enforceSecure = buf.readBoolean();
|
enforceSecure = buf.readBoolean();
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class ServerData extends DefinedPacket
|
|||||||
buf.writeBoolean( true );
|
buf.writeBoolean( true );
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_4 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_4 )
|
||||||
{
|
{
|
||||||
writeArray( (byte[]) icon, buf );
|
DefinedPacket.writeArray( (byte[]) icon, buf );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
writeString( (String) icon, buf );
|
writeString( (String) icon, buf );
|
||||||
@ -91,7 +91,7 @@ public class ServerData extends DefinedPacket
|
|||||||
buf.writeBoolean( preview );
|
buf.writeBoolean( preview );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 && protocolVersion < ProtocolConstants.MINECRAFT_1_20_5 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
||||||
{
|
{
|
||||||
buf.writeBoolean( enforceSecure );
|
buf.writeBoolean( enforceSecure );
|
||||||
}
|
}
|
||||||
|
@ -1,41 +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 StoreCookie extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private String key;
|
|
||||||
private byte[] data;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
key = readString( buf );
|
|
||||||
data = readArray( buf, 5120 );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
writeString( key, buf );
|
|
||||||
writeArray( data, buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +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 Transfer extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private String host;
|
|
||||||
private int port;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
host = readString( buf );
|
|
||||||
port = readVarInt( buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
writeString( host, buf );
|
|
||||||
writeVarInt( port, buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import se.llbit.nbt.SpecificTag;
|
|
||||||
|
|
||||||
public class TagUtilTest
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final Gson GSON = new Gson();
|
|
||||||
|
|
||||||
private static void testDissembleReassemble(String json)
|
|
||||||
{
|
|
||||||
JsonElement parsedJson = GSON.fromJson( json, JsonElement.class );
|
|
||||||
SpecificTag nbt = TagUtil.fromJson( parsedJson );
|
|
||||||
JsonElement convertedElement = TagUtil.toJson( nbt );
|
|
||||||
|
|
||||||
String convertedJson = GSON.toJson( convertedElement );
|
|
||||||
assertEquals( json, convertedJson );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStringLiteral()
|
|
||||||
{
|
|
||||||
testDissembleReassemble( "{\"text\":\"\",\"extra\":[\"hello\",{\"text\":\"there\",\"color\":\"#ff0000\"},{\"text\":\"friend\",\"font\":\"minecraft:default\"}]}" );
|
|
||||||
}
|
|
||||||
}
|
|
@ -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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-proxy</artifactId>
|
<artifactId>bungeecord-proxy</artifactId>
|
||||||
<version>1.20-R0.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Proxy</name>
|
<name>BungeeCord-Proxy</name>
|
||||||
@ -96,26 +96,26 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>com.mysql</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
<version>8.2.0</version>
|
<version>8.1.0</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- add these back in as they are not exposed by the API -->
|
<!-- add these back in as they are not exposed by the API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-resolver-provider</artifactId>
|
<artifactId>maven-resolver-provider</artifactId>
|
||||||
<version>3.9.6</version>
|
<version>3.8.5</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.resolver</groupId>
|
<groupId>org.apache.maven.resolver</groupId>
|
||||||
<artifactId>maven-resolver-connector-basic</artifactId>
|
<artifactId>maven-resolver-connector-basic</artifactId>
|
||||||
<version>1.9.18</version>
|
<version>1.7.3</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.resolver</groupId>
|
<groupId>org.apache.maven.resolver</groupId>
|
||||||
<artifactId>maven-resolver-transport-http</artifactId>
|
<artifactId>maven-resolver-transport-http</artifactId>
|
||||||
<version>1.9.18</version>
|
<version>1.7.3</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -58,7 +58,6 @@ import net.md_5.bungee.api.ReconnectHandler;
|
|||||||
import net.md_5.bungee.api.ServerPing;
|
import net.md_5.bungee.api.ServerPing;
|
||||||
import net.md_5.bungee.api.Title;
|
import net.md_5.bungee.api.Title;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.ComponentStyle;
|
|
||||||
import net.md_5.bungee.api.chat.KeybindComponent;
|
import net.md_5.bungee.api.chat.KeybindComponent;
|
||||||
import net.md_5.bungee.api.chat.ScoreComponent;
|
import net.md_5.bungee.api.chat.ScoreComponent;
|
||||||
import net.md_5.bungee.api.chat.SelectorComponent;
|
import net.md_5.bungee.api.chat.SelectorComponent;
|
||||||
@ -71,7 +70,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.md_5.bungee.api.plugin.PluginManager;
|
import net.md_5.bungee.api.plugin.PluginManager;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
import net.md_5.bungee.chat.ComponentStyleSerializer;
|
|
||||||
import net.md_5.bungee.chat.KeybindComponentSerializer;
|
import net.md_5.bungee.chat.KeybindComponentSerializer;
|
||||||
import net.md_5.bungee.chat.ScoreComponentSerializer;
|
import net.md_5.bungee.chat.ScoreComponentSerializer;
|
||||||
import net.md_5.bungee.chat.SelectorComponentSerializer;
|
import net.md_5.bungee.chat.SelectorComponentSerializer;
|
||||||
@ -171,7 +169,6 @@ public class BungeeCord extends ProxyServer
|
|||||||
.registerTypeAdapter( KeybindComponent.class, new KeybindComponentSerializer() )
|
.registerTypeAdapter( KeybindComponent.class, new KeybindComponentSerializer() )
|
||||||
.registerTypeAdapter( ScoreComponent.class, new ScoreComponentSerializer() )
|
.registerTypeAdapter( ScoreComponent.class, new ScoreComponentSerializer() )
|
||||||
.registerTypeAdapter( SelectorComponent.class, new SelectorComponentSerializer() )
|
.registerTypeAdapter( SelectorComponent.class, new SelectorComponentSerializer() )
|
||||||
.registerTypeAdapter( ComponentStyle.class, new ComponentStyleSerializer() )
|
|
||||||
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer() )
|
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer() )
|
||||||
.registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create();
|
.registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create();
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -73,8 +73,7 @@ public class EncryptionUtil
|
|||||||
byte[] pubKey = keys.getPublic().getEncoded();
|
byte[] pubKey = keys.getPublic().getEncoded();
|
||||||
byte[] verify = new byte[ 4 ];
|
byte[] verify = new byte[ 4 ];
|
||||||
random.nextBytes( verify );
|
random.nextBytes( verify );
|
||||||
// always auth for now
|
return new EncryptionRequest( hash, pubKey, verify );
|
||||||
return new EncryptionRequest( hash, pubKey, verify, true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean check(PlayerPublicKey publicKey, UUID uuid) throws GeneralSecurityException
|
public static boolean check(PlayerPublicKey publicKey, UUID uuid) throws GeneralSecurityException
|
||||||
|
@ -10,7 +10,6 @@ import java.util.Locale;
|
|||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
@ -40,8 +39,6 @@ import net.md_5.bungee.protocol.Either;
|
|||||||
import net.md_5.bungee.protocol.PacketWrapper;
|
import net.md_5.bungee.protocol.PacketWrapper;
|
||||||
import net.md_5.bungee.protocol.Protocol;
|
import net.md_5.bungee.protocol.Protocol;
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||||
import net.md_5.bungee.protocol.packet.CookieRequest;
|
|
||||||
import net.md_5.bungee.protocol.packet.CookieResponse;
|
|
||||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||||
import net.md_5.bungee.protocol.packet.EntityStatus;
|
import net.md_5.bungee.protocol.packet.EntityStatus;
|
||||||
import net.md_5.bungee.protocol.packet.GameState;
|
import net.md_5.bungee.protocol.packet.GameState;
|
||||||
@ -190,12 +187,6 @@ public class ServerConnector extends PacketHandler
|
|||||||
ch.setCompressionThreshold( setCompression.getThreshold() );
|
ch.setCompressionThreshold( setCompression.getThreshold() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(CookieRequest cookieRequest) throws Exception
|
|
||||||
{
|
|
||||||
user.retrieveCookie( cookieRequest.getCookie() ).thenAccept( (cookie) -> ch.write( new CookieResponse( cookieRequest.getCookie(), cookie ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Login login) throws Exception
|
public void handle(Login login) throws Exception
|
||||||
{
|
{
|
||||||
@ -252,7 +243,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
// Set tab list size, TODO: what shall we do about packet mutability
|
// Set tab list size, TODO: what shall we do about packet mutability
|
||||||
Login modLogin = new Login( login.getEntityId(), login.isHardcore(), login.getGameMode(), login.getPreviousGameMode(), login.getWorldNames(), login.getDimensions(), login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(),
|
Login modLogin = new Login( login.getEntityId(), login.isHardcore(), login.getGameMode(), login.getPreviousGameMode(), login.getWorldNames(), login.getDimensions(), login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(),
|
||||||
(byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.getSimulationDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isLimitedCrafting(), login.isDebug(), login.isFlat(), login.getDeathLocation(),
|
(byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.getSimulationDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isLimitedCrafting(), login.isDebug(), login.isFlat(), login.getDeathLocation(),
|
||||||
login.getPortalCooldown(), login.isSecureProfile() );
|
login.getPortalCooldown() );
|
||||||
|
|
||||||
user.unsafe().sendPacket( modLogin );
|
user.unsafe().sendPacket( modLogin );
|
||||||
|
|
||||||
@ -348,14 +339,6 @@ public class ServerConnector extends PacketHandler
|
|||||||
|
|
||||||
private void cutThrough(ServerConnection server)
|
private void cutThrough(ServerConnection server)
|
||||||
{
|
{
|
||||||
// TODO: Fix this?
|
|
||||||
if ( !user.isActive() )
|
|
||||||
{
|
|
||||||
server.disconnect( "Quitting" );
|
|
||||||
bungee.getLogger().log( Level.WARNING, "[{0}] No client connected for pending server!", user );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_20_2 )
|
if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_20_2 )
|
||||||
{
|
{
|
||||||
if ( user.getServer() != null )
|
if ( user.getServer() != null )
|
||||||
@ -377,6 +360,15 @@ public class ServerConnector extends PacketHandler
|
|||||||
user.getServer().disconnect( "Quitting" );
|
user.getServer().disconnect( "Quitting" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Fix this?
|
||||||
|
if ( !user.isActive() )
|
||||||
|
{
|
||||||
|
server.disconnect( "Quitting" );
|
||||||
|
// Silly server admins see stack trace and die
|
||||||
|
bungee.getLogger().warning( "No client connected for pending server!" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Add to new server
|
// Add to new server
|
||||||
// TODO: Move this to the connected() method of DownstreamBridge
|
// TODO: Move this to the connected() method of DownstreamBridge
|
||||||
target.addPlayer( user );
|
target.addPlayer( user );
|
||||||
|
@ -20,7 +20,6 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -61,9 +60,7 @@ import net.md_5.bungee.protocol.packet.Kick;
|
|||||||
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
|
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
|
||||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||||
import net.md_5.bungee.protocol.packet.StoreCookie;
|
|
||||||
import net.md_5.bungee.protocol.packet.SystemChat;
|
import net.md_5.bungee.protocol.packet.SystemChat;
|
||||||
import net.md_5.bungee.protocol.packet.Transfer;
|
|
||||||
import net.md_5.bungee.tab.ServerUnique;
|
import net.md_5.bungee.tab.ServerUnique;
|
||||||
import net.md_5.bungee.tab.TabList;
|
import net.md_5.bungee.tab.TabList;
|
||||||
import net.md_5.bungee.util.CaseInsensitiveSet;
|
import net.md_5.bungee.util.CaseInsensitiveSet;
|
||||||
@ -774,26 +771,4 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
{
|
{
|
||||||
return serverSentScoreboard;
|
return serverSentScoreboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<byte[]> retrieveCookie(String cookie)
|
|
||||||
{
|
|
||||||
return pendingConnection.retrieveCookie( cookie );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void storeCookie(String cookie, byte[] data)
|
|
||||||
{
|
|
||||||
Preconditions.checkState( getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_20_5, "Cookies are only supported in 1.20.5 and above" );
|
|
||||||
|
|
||||||
unsafe().sendPacket( new StoreCookie( cookie, data ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void transfer(String host, int port)
|
|
||||||
{
|
|
||||||
Preconditions.checkState( getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_20_5, "Transfers are only supported in 1.20.5 and above" );
|
|
||||||
|
|
||||||
unsafe().sendPacket( new Transfer( host, port ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,6 @@ public class Configuration implements ProxyConfig
|
|||||||
private int compressionThreshold = 256;
|
private int compressionThreshold = 256;
|
||||||
private boolean preventProxyConnections;
|
private boolean preventProxyConnections;
|
||||||
private boolean forgeSupport;
|
private boolean forgeSupport;
|
||||||
private boolean rejectTransfers;
|
|
||||||
|
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
@ -104,7 +103,6 @@ public class Configuration implements ProxyConfig
|
|||||||
compressionThreshold = adapter.getInt( "network_compression_threshold", compressionThreshold );
|
compressionThreshold = adapter.getInt( "network_compression_threshold", compressionThreshold );
|
||||||
preventProxyConnections = adapter.getBoolean( "prevent_proxy_connections", preventProxyConnections );
|
preventProxyConnections = adapter.getBoolean( "prevent_proxy_connections", preventProxyConnections );
|
||||||
forgeSupport = adapter.getBoolean( "forge_support", forgeSupport );
|
forgeSupport = adapter.getBoolean( "forge_support", forgeSupport );
|
||||||
rejectTransfers = adapter.getBoolean( "reject_transfers", rejectTransfers );
|
|
||||||
|
|
||||||
disabledCommands = new CaseInsensitiveSet( (Collection<String>) adapter.getList( "disabled_commands", Arrays.asList( "disabledcommandhere" ) ) );
|
disabledCommands = new CaseInsensitiveSet( (Collection<String>) adapter.getList( "disabled_commands", Arrays.asList( "disabledcommandhere" ) ) );
|
||||||
|
|
||||||
|
@ -11,19 +11,12 @@ import java.security.GeneralSecurityException;
|
|||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.ToString;
|
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.BungeeServerInfo;
|
import net.md_5.bungee.BungeeServerInfo;
|
||||||
import net.md_5.bungee.EncryptionUtil;
|
import net.md_5.bungee.EncryptionUtil;
|
||||||
@ -58,8 +51,6 @@ import net.md_5.bungee.protocol.PacketWrapper;
|
|||||||
import net.md_5.bungee.protocol.PlayerPublicKey;
|
import net.md_5.bungee.protocol.PlayerPublicKey;
|
||||||
import net.md_5.bungee.protocol.Protocol;
|
import net.md_5.bungee.protocol.Protocol;
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||||
import net.md_5.bungee.protocol.packet.CookieRequest;
|
|
||||||
import net.md_5.bungee.protocol.packet.CookieResponse;
|
|
||||||
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.Handshake;
|
import net.md_5.bungee.protocol.packet.Handshake;
|
||||||
@ -95,19 +86,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
@Getter
|
@Getter
|
||||||
private final Set<String> registeredChannels = new HashSet<>();
|
private final Set<String> registeredChannels = new HashSet<>();
|
||||||
private State thisState = State.HANDSHAKE;
|
private State thisState = State.HANDSHAKE;
|
||||||
private final Queue<CookieFuture> requestedCookies = new LinkedList<>();
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@AllArgsConstructor
|
|
||||||
public static class CookieFuture
|
|
||||||
{
|
|
||||||
|
|
||||||
private String cookie;
|
|
||||||
private CompletableFuture<byte[]> future;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Unsafe unsafe = new Unsafe()
|
private final Unsafe unsafe = new Unsafe()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -131,8 +109,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
private boolean legacy;
|
private boolean legacy;
|
||||||
@Getter
|
@Getter
|
||||||
private String extraDataInHandshake = "";
|
private String extraDataInHandshake = "";
|
||||||
@Getter
|
|
||||||
private boolean transferred;
|
|
||||||
private UserConnection userCon;
|
private UserConnection userCon;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -373,8 +349,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
ch.setProtocol( Protocol.STATUS );
|
ch.setProtocol( Protocol.STATUS );
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
|
||||||
transferred = handshake.getRequestedProtocol() == 3;
|
|
||||||
// Login
|
// Login
|
||||||
bungee.getLogger().log( Level.INFO, "{0} has connected", this );
|
bungee.getLogger().log( Level.INFO, "{0} has connected", this );
|
||||||
thisState = State.USERNAME;
|
thisState = State.USERNAME;
|
||||||
@ -391,12 +365,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( transferred && bungee.config.isRejectTransfers() )
|
|
||||||
{
|
|
||||||
disconnect( bungee.getTranslation( "reject_transfer" ) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new QuietException( "Cannot request protocol " + handshake.getRequestedProtocol() );
|
throw new QuietException( "Cannot request protocol " + handshake.getRequestedProtocol() );
|
||||||
@ -653,13 +621,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
|
|
||||||
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
||||||
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
|
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
|
||||||
|
|
||||||
// #3612: Don't progress further if disconnected during event
|
|
||||||
if ( ch.isClosed() )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerInfo server;
|
ServerInfo server;
|
||||||
if ( bungee.getReconnectHandler() != null )
|
if ( bungee.getReconnectHandler() != null )
|
||||||
{
|
{
|
||||||
@ -682,34 +643,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
disconnect( "Unexpected custom LoginPayloadResponse" );
|
disconnect( "Unexpected custom LoginPayloadResponse" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(CookieResponse cookieResponse)
|
|
||||||
{
|
|
||||||
// be careful, backend server could also make the client send a cookie response
|
|
||||||
CookieFuture future;
|
|
||||||
synchronized ( requestedCookies )
|
|
||||||
{
|
|
||||||
future = requestedCookies.peek();
|
|
||||||
if ( future != null )
|
|
||||||
{
|
|
||||||
if ( future.cookie.equals( cookieResponse.getCookie() ) )
|
|
||||||
{
|
|
||||||
Preconditions.checkState( future == requestedCookies.poll(), "requestedCookies queue mismatch" );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
future = null; // leave for handling by backend
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( future != null )
|
|
||||||
{
|
|
||||||
future.getFuture().complete( cookieResponse.getData() );
|
|
||||||
|
|
||||||
throw CancelSendSignal.INSTANCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect(String reason)
|
public void disconnect(String reason)
|
||||||
{
|
{
|
||||||
@ -842,26 +775,4 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
brandMessage = input;
|
brandMessage = input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<byte[]> retrieveCookie(String cookie)
|
|
||||||
{
|
|
||||||
Preconditions.checkState( getVersion() >= ProtocolConstants.MINECRAFT_1_20_5, "Cookies are only supported in 1.20.5 and above" );
|
|
||||||
Preconditions.checkState( loginRequest != null, "Cannot retrieve cookies for status or legacy connections" );
|
|
||||||
|
|
||||||
if ( cookie.indexOf( ':' ) == -1 )
|
|
||||||
{
|
|
||||||
// if we request an invalid resource location (no prefix) the client will respond with "minecraft:" prefix
|
|
||||||
cookie = "minecraft:" + cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompletableFuture<byte[]> future = new CompletableFuture<>();
|
|
||||||
synchronized ( requestedCookies )
|
|
||||||
{
|
|
||||||
requestedCookies.add( new CookieFuture( cookie, future ) );
|
|
||||||
}
|
|
||||||
unsafe.sendPacket( new CookieRequest( cookie ) );
|
|
||||||
|
|
||||||
return future;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ import net.md_5.bungee.protocol.packet.Chat;
|
|||||||
import net.md_5.bungee.protocol.packet.ClientChat;
|
import net.md_5.bungee.protocol.packet.ClientChat;
|
||||||
import net.md_5.bungee.protocol.packet.ClientCommand;
|
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.CookieResponse;
|
|
||||||
import net.md_5.bungee.protocol.packet.FinishConfiguration;
|
import net.md_5.bungee.protocol.packet.FinishConfiguration;
|
||||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||||
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
|
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
|
||||||
@ -129,7 +128,7 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public boolean shouldHandle(PacketWrapper packet) throws Exception
|
public boolean shouldHandle(PacketWrapper packet) throws Exception
|
||||||
{
|
{
|
||||||
return con.getServer() != null || packet.packet instanceof PluginMessage || packet.packet instanceof CookieResponse;
|
return con.getServer() != null || packet.packet instanceof PluginMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -364,12 +363,6 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
con.sendQueuedPackets();
|
con.sendQueuedPackets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(CookieResponse cookieResponse) throws Exception
|
|
||||||
{
|
|
||||||
con.getPendingConnection().handle( cookieResponse );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@ -86,8 +86,6 @@ public abstract class EntityMap
|
|||||||
return EntityMap_1_16_2.INSTANCE_1_20_2;
|
return EntityMap_1_16_2.INSTANCE_1_20_2;
|
||||||
case ProtocolConstants.MINECRAFT_1_20_3:
|
case ProtocolConstants.MINECRAFT_1_20_3:
|
||||||
return EntityMap_1_16_2.INSTANCE_1_20_3;
|
return EntityMap_1_16_2.INSTANCE_1_20_3;
|
||||||
case ProtocolConstants.MINECRAFT_1_20_5:
|
|
||||||
return EntityMap_1_16_2.INSTANCE_1_20_5;
|
|
||||||
}
|
}
|
||||||
throw new RuntimeException( "Version " + version + " has no entity map" );
|
throw new RuntimeException( "Version " + version + " has no entity map" );
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ class EntityMap_1_16_2 extends EntityMap
|
|||||||
static final EntityMap_1_16_2 INSTANCE_1_19_4 = new EntityMap_1_16_2( 0x03, 0x30 );
|
static final EntityMap_1_16_2 INSTANCE_1_19_4 = new EntityMap_1_16_2( 0x03, 0x30 );
|
||||||
static final EntityMap_1_16_2 INSTANCE_1_20_2 = new EntityMap_1_16_2( -1, 0x33 );
|
static final EntityMap_1_16_2 INSTANCE_1_20_2 = new EntityMap_1_16_2( -1, 0x33 );
|
||||||
static final EntityMap_1_16_2 INSTANCE_1_20_3 = new EntityMap_1_16_2( -1, 0x34 );
|
static final EntityMap_1_16_2 INSTANCE_1_20_3 = new EntityMap_1_16_2( -1, 0x34 );
|
||||||
static final EntityMap_1_16_2 INSTANCE_1_20_5 = new EntityMap_1_16_2( -1, 0x36 );
|
|
||||||
//
|
//
|
||||||
private final int spawnPlayerId;
|
private final int spawnPlayerId;
|
||||||
private final int spectateId;
|
private final int spectateId;
|
||||||
|
@ -40,4 +40,3 @@ command_perms_permission=\u00a79- {0}
|
|||||||
command_ip=\u00a79IP of {0} is {1}
|
command_ip=\u00a79IP of {0} is {1}
|
||||||
illegal_chat_characters=\u00a7cIllegal characters in chat ({0})
|
illegal_chat_characters=\u00a7cIllegal characters in chat ({0})
|
||||||
kick_message=\u00a7cYou have been kicked off the proxy.
|
kick_message=\u00a7cYou have been kicked off the proxy.
|
||||||
reject_transfer=\u00a7cYour transfer was rejected.
|
|
||||||
|
@ -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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-query</artifactId>
|
<artifactId>bungeecord-query</artifactId>
|
||||||
<version>1.20-R0.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Query</name>
|
<name>BungeeCord-Query</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.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-slf4j</artifactId>
|
<artifactId>bungeecord-slf4j</artifactId>
|
||||||
<version>1.20-R0.3-SNAPSHOT</version>
|
<version>1.20-R0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-SLF4J</name>
|
<name>BungeeCord-SLF4J</name>
|
||||||
|
Loading…
Reference in New Issue
Block a user