Compare commits
No commits in common. "5a1e342e0d500bfbab77dcfda24273e971a28b02" and "68200133b6aa06d9fd257e47c11cfe734ec001bf" have entirely different histories.
5a1e342e0d
...
68200133b6
3
.github/dependabot.yml
vendored
3
.github/dependabot.yml
vendored
@ -13,10 +13,9 @@ 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"
|
||||||
# Later versions of these Maven dependencies are incompatible and require careful management - see SPIGOT-7400
|
# Needs to be synchronised with maven-resolver-provider dependencies
|
||||||
- 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"]
|
||||||
|
4
.github/workflows/maven.yml
vendored
4
.github/workflows/maven.yml
vendored
@ -9,12 +9,12 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
java: [8, 11, 17, 21]
|
java: [8, 11, 17]
|
||||||
|
|
||||||
name: Java ${{ matrix.java }}
|
name: Java ${{ matrix.java }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-java@v3
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: zulu
|
distribution: zulu
|
||||||
|
12
api/pom.xml
12
api/pom.xml
@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-api</artifactId>
|
<artifactId>bungeecord-api</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-API</name>
|
<name>BungeeCord-API</name>
|
||||||
@ -51,28 +51,28 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-resolver-provider</artifactId>
|
<artifactId>maven-resolver-provider</artifactId>
|
||||||
<version>3.8.5</version>
|
<version>3.9.2</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.7.3</version>
|
<version>1.9.10</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.7.3</version>
|
<version>1.9.10</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.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
<version>2.2</version>
|
<version>2.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-bootstrap</artifactId>
|
<artifactId>bungeecord-bootstrap</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Bootstrap</name>
|
<name>BungeeCord-Bootstrap</name>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.4.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-chat</artifactId>
|
<artifactId>bungeecord-chat</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Chat</name>
|
<name>BungeeCord-Chat</name>
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.10.1</version>
|
<version>2.10</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -454,32 +454,9 @@ public final class ComponentBuilder
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the component built by this builder. If this builder is
|
|
||||||
* empty, an empty text component will be returned.
|
|
||||||
*
|
|
||||||
* @return the component
|
|
||||||
*/
|
|
||||||
public BaseComponent build()
|
|
||||||
{
|
|
||||||
TextComponent base = new TextComponent();
|
|
||||||
if ( !parts.isEmpty() )
|
|
||||||
{
|
|
||||||
List<BaseComponent> cloned = new ArrayList<>( parts );
|
|
||||||
cloned.replaceAll( BaseComponent::duplicate );
|
|
||||||
base.setExtra( cloned );
|
|
||||||
}
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the components needed to display the message created by this
|
* Returns the components needed to display the message created by this
|
||||||
* builder.git
|
* builder.git
|
||||||
* <p>
|
|
||||||
* <strong>NOTE:</strong> {@link #build()} is preferred as it will
|
|
||||||
* consolidate all components into a single BaseComponent with extra
|
|
||||||
* contents as opposed to an array of components which is non-standard
|
|
||||||
* and may result in unexpected behavior.
|
|
||||||
*
|
*
|
||||||
* @return the created components
|
* @return the created components
|
||||||
*/
|
*/
|
||||||
|
@ -23,12 +23,6 @@ public class Text extends Content
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Text(BaseComponent value)
|
|
||||||
{
|
|
||||||
// For legacy serialization reasons, this has to be an array of components
|
|
||||||
this( new BaseComponent[]{value} );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Text(String value)
|
public Text(String value)
|
||||||
{
|
{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
@ -27,6 +27,7 @@ import net.md_5.bungee.api.chat.hover.content.TextSerializer;
|
|||||||
public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||||
private static final Gson gson = new GsonBuilder().
|
private static final Gson gson = new GsonBuilder().
|
||||||
registerTypeAdapter( BaseComponent.class, new ComponentSerializer() ).
|
registerTypeAdapter( BaseComponent.class, new ComponentSerializer() ).
|
||||||
registerTypeAdapter( TextComponent.class, new TextComponentSerializer() ).
|
registerTypeAdapter( TextComponent.class, new TextComponentSerializer() ).
|
||||||
@ -42,25 +43,9 @@ public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
|||||||
|
|
||||||
public static final ThreadLocal<Set<BaseComponent>> serializedComponents = new ThreadLocal<Set<BaseComponent>>();
|
public static final ThreadLocal<Set<BaseComponent>> serializedComponents = new ThreadLocal<Set<BaseComponent>>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a JSON-compliant String as an array of base components. The input
|
|
||||||
* can be one of either an array of components, or a single component object.
|
|
||||||
* If the input is an array, each component will be parsed individually and
|
|
||||||
* returned in the order that they were parsed. If the input is a single
|
|
||||||
* component object, a single-valued array with the component will be returned.
|
|
||||||
* <p>
|
|
||||||
* <strong>NOTE:</strong> {@link #deserialize(String)} is preferred as it will
|
|
||||||
* parse only one component as opposed to an array of components which is non-
|
|
||||||
* standard behavior. This method is still appropriate for parsing multiple
|
|
||||||
* components at once, although such use case is rarely (if at all) exhibited
|
|
||||||
* in vanilla Minecraft.
|
|
||||||
*
|
|
||||||
* @param json the component json to parse
|
|
||||||
* @return an array of all parsed components
|
|
||||||
*/
|
|
||||||
public static BaseComponent[] parse(String json)
|
public static BaseComponent[] parse(String json)
|
||||||
{
|
{
|
||||||
JsonElement jsonElement = JsonParser.parseString( json );
|
JsonElement jsonElement = JSON_PARSER.parse( json );
|
||||||
|
|
||||||
if ( jsonElement.isJsonArray() )
|
if ( jsonElement.isJsonArray() )
|
||||||
{
|
{
|
||||||
@ -74,26 +59,6 @@ public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserialize a JSON-compliant String as a single component. The input is
|
|
||||||
* expected to be a JSON object that represents only one component.
|
|
||||||
*
|
|
||||||
* @param json the component json to parse
|
|
||||||
* @return the deserialized component
|
|
||||||
* @throws IllegalArgumentException if anything other than a JSON object is
|
|
||||||
* passed as input
|
|
||||||
*/
|
|
||||||
public static BaseComponent deserialize(String json)
|
|
||||||
{
|
|
||||||
JsonElement jsonElement = JsonParser.parseString( json );
|
|
||||||
if ( !jsonElement.isJsonObject() )
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException( "Malformatted JSON. Expected object, got array for input \"" + json + "\"." );
|
|
||||||
}
|
|
||||||
|
|
||||||
return gson.fromJson( jsonElement, BaseComponent.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toString(Object object)
|
public static String toString(Object object)
|
||||||
{
|
{
|
||||||
return gson.toJson( object );
|
return gson.toJson( object );
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
package net.md_5.bungee.api.chat;
|
package net.md_5.bungee.api.chat;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.ObjIntConsumer;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.hover.content.Item;
|
import net.md_5.bungee.api.chat.hover.content.Item;
|
||||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||||
@ -23,24 +18,10 @@ public class ComponentsTest
|
|||||||
Assert.assertEquals( TextComponent.toLegacyText( parsed ), TextComponent.toLegacyText( components ) );
|
Assert.assertEquals( TextComponent.toLegacyText( parsed ), TextComponent.toLegacyText( components ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void testDissembleReassemble(BaseComponent component)
|
public static void testDissembleReassemble(String json)
|
||||||
{
|
{
|
||||||
String json = ComponentSerializer.toString( component );
|
|
||||||
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
||||||
Assert.assertEquals( TextComponent.toLegacyText( parsed ), TextComponent.toLegacyText( component ) );
|
Assert.assertEquals( json, ComponentSerializer.toString( parsed ) );
|
||||||
}
|
|
||||||
|
|
||||||
public static void testAssembleDissemble(String json, boolean modern)
|
|
||||||
{
|
|
||||||
if ( modern )
|
|
||||||
{
|
|
||||||
BaseComponent deserialized = ComponentSerializer.deserialize( json );
|
|
||||||
Assert.assertEquals( json, ComponentSerializer.toString( deserialized ) );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
|
||||||
Assert.assertEquals( json, ComponentSerializer.toString( parsed ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -60,10 +41,8 @@ public class ComponentsTest
|
|||||||
{
|
{
|
||||||
textComponent
|
textComponent
|
||||||
} );
|
} );
|
||||||
testDissembleReassemble( textComponent );
|
|
||||||
json = "{\"hoverEvent\":{\"action\":\"show_item\",\"value\":[{\"text\":\"{id:\\\"minecraft:netherrack\\\",Count:47b}\"}]},\"text\":\"Test\"}";
|
json = "{\"hoverEvent\":{\"action\":\"show_item\",\"value\":[{\"text\":\"{id:\\\"minecraft:netherrack\\\",Count:47b}\"}]},\"text\":\"Test\"}";
|
||||||
testAssembleDissemble( json, false );
|
testDissembleReassemble( json );
|
||||||
testAssembleDissemble( json, true );
|
|
||||||
//////////
|
//////////
|
||||||
String hoverVal = "{\"text\":\"{id:\\\"minecraft:dirt\\\",Count:1b}\"}";
|
String hoverVal = "{\"text\":\"{id:\\\"minecraft:dirt\\\",Count:1b}\"}";
|
||||||
json = "{\"extra\":[{\"text\":\"[\"},{\"extra\":[{\"translate\":\"block.minecraft.dirt\"}],\"text\":\"\"},{\"text\":\"]\"}],\"hoverEvent\":{\"action\":\"show_item\",\"value\":[" + hoverVal + "]},\"text\":\"\"}";
|
json = "{\"extra\":[{\"text\":\"[\"},{\"extra\":[{\"translate\":\"block.minecraft.dirt\"}],\"text\":\"\"},{\"text\":\"]\"}],\"hoverEvent\":{\"action\":\"show_item\",\"value\":[" + hoverVal + "]},\"text\":\"\"}";
|
||||||
@ -87,37 +66,18 @@ public class ComponentsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyComponentBuilderCreate()
|
public void testEmptyComponentBuilder()
|
||||||
{
|
|
||||||
this.testEmptyComponentBuilder(
|
|
||||||
ComponentBuilder::create,
|
|
||||||
(components) -> Assert.assertEquals( components.length, 0 ),
|
|
||||||
(components, size) -> Assert.assertEquals( size, components.length )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testEmptyComponentBuilderBuild()
|
|
||||||
{
|
|
||||||
this.testEmptyComponentBuilder(
|
|
||||||
ComponentBuilder::build,
|
|
||||||
(component) -> Assert.assertNull( component.getExtra() ),
|
|
||||||
(component, size) -> Assert.assertEquals( component.getExtra().size(), size )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testEmptyComponentBuilder(Function<ComponentBuilder, T> componentBuilder, Consumer<T> emptyAssertion, ObjIntConsumer<T> sizedAssertion)
|
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder();
|
ComponentBuilder builder = new ComponentBuilder();
|
||||||
|
|
||||||
T component = componentBuilder.apply( builder );
|
BaseComponent[] parts = builder.create();
|
||||||
emptyAssertion.accept( component );
|
Assert.assertEquals( parts.length, 0 );
|
||||||
|
|
||||||
for ( int i = 0; i < 3; i++ )
|
for ( int i = 0; i < 3; i++ )
|
||||||
{
|
{
|
||||||
builder.append( "part:" + i );
|
builder.append( "part:" + i );
|
||||||
component = componentBuilder.apply( builder );
|
parts = builder.create();
|
||||||
sizedAssertion.accept( component, i + 1 );
|
Assert.assertEquals( parts.length, i + 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +213,7 @@ public class ComponentsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHoverEventContentsCreate()
|
public void testHoverEventContents()
|
||||||
{
|
{
|
||||||
// First do the text using the newer contents system
|
// First do the text using the newer contents system
|
||||||
HoverEvent hoverEvent = new HoverEvent(
|
HoverEvent hoverEvent = new HoverEvent(
|
||||||
@ -262,53 +222,21 @@ public class ComponentsTest
|
|||||||
new Text( new ComponentBuilder( "Second" ).create() )
|
new Text( new ComponentBuilder( "Second" ).create() )
|
||||||
);
|
);
|
||||||
|
|
||||||
this.testHoverEventContents(
|
|
||||||
hoverEvent,
|
|
||||||
ComponentSerializer::parse,
|
|
||||||
(components) -> components[0].getHoverEvent(),
|
|
||||||
ComponentsTest::testDissembleReassemble // BaseComponent
|
|
||||||
);
|
|
||||||
|
|
||||||
// check the test still works with the value method
|
|
||||||
hoverEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Sample text" ).create() );
|
|
||||||
TextComponent component = new TextComponent( "Sample text" );
|
|
||||||
component.setHoverEvent( hoverEvent );
|
|
||||||
|
|
||||||
Assert.assertEquals( hoverEvent.getContents().size(), 1 );
|
|
||||||
Assert.assertTrue( hoverEvent.isLegacy() );
|
|
||||||
String serialized = ComponentSerializer.toString( component );
|
|
||||||
BaseComponent[] deserialized = ComponentSerializer.parse( serialized );
|
|
||||||
Assert.assertEquals( component.getHoverEvent(), deserialized[0].getHoverEvent() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testHoverEventContentsBuild()
|
|
||||||
{
|
|
||||||
// First do the text using the newer contents system
|
|
||||||
HoverEvent hoverEvent = new HoverEvent(
|
|
||||||
HoverEvent.Action.SHOW_TEXT,
|
|
||||||
new Text( new ComponentBuilder( "First" ).build() ),
|
|
||||||
new Text( new ComponentBuilder( "Second" ).build() )
|
|
||||||
);
|
|
||||||
|
|
||||||
this.testHoverEventContents(
|
|
||||||
hoverEvent,
|
|
||||||
ComponentSerializer::deserialize,
|
|
||||||
BaseComponent::getHoverEvent,
|
|
||||||
ComponentsTest::testDissembleReassemble // BaseComponent
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testHoverEventContents(HoverEvent hoverEvent, Function<String, T> deserializer, Function<T, HoverEvent> hoverEventGetter, Consumer<T> dissembleReassembleTest)
|
|
||||||
{
|
|
||||||
TextComponent component = new TextComponent( "Sample text" );
|
TextComponent component = new TextComponent( "Sample text" );
|
||||||
component.setHoverEvent( hoverEvent );
|
component.setHoverEvent( hoverEvent );
|
||||||
Assert.assertEquals( hoverEvent.getContents().size(), 2 );
|
Assert.assertEquals( hoverEvent.getContents().size(), 2 );
|
||||||
Assert.assertFalse( hoverEvent.isLegacy() );
|
Assert.assertFalse( hoverEvent.isLegacy() );
|
||||||
|
|
||||||
String serialized = ComponentSerializer.toString( component );
|
String serialized = ComponentSerializer.toString( component );
|
||||||
T deserialized = deserializer.apply( serialized );
|
BaseComponent[] deserialized = ComponentSerializer.parse( serialized );
|
||||||
Assert.assertEquals( component.getHoverEvent(), hoverEventGetter.apply( deserialized ) );
|
Assert.assertEquals( component.getHoverEvent(), deserialized[0].getHoverEvent() );
|
||||||
|
|
||||||
|
// check the test still works with the value method
|
||||||
|
hoverEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Sample text" ).create() );
|
||||||
|
Assert.assertEquals( hoverEvent.getContents().size(), 1 );
|
||||||
|
Assert.assertTrue( hoverEvent.isLegacy() );
|
||||||
|
serialized = ComponentSerializer.toString( component );
|
||||||
|
deserialized = ComponentSerializer.parse( serialized );
|
||||||
|
Assert.assertEquals( component.getHoverEvent(), deserialized[0].getHoverEvent() );
|
||||||
|
|
||||||
// Test single content:
|
// Test single content:
|
||||||
String json = "{\"italic\":true,\"color\":\"gray\",\"translate\":\"chat.type.admin\",\"with\":[{\"text\":\"@\"}"
|
String json = "{\"italic\":true,\"color\":\"gray\",\"translate\":\"chat.type.admin\",\"with\":[{\"text\":\"@\"}"
|
||||||
@ -320,28 +248,17 @@ public class ComponentsTest
|
|||||||
+ "\"/tell Name \"},\"hoverEvent\":{\"action\":\"show_entity\",\"contents\":"
|
+ "\"/tell Name \"},\"hoverEvent\":{\"action\":\"show_entity\",\"contents\":"
|
||||||
+ "{\"type\":\"minecraft:player\",\"id\":\"00000000-0000-0000-0000-00000000000000\",\"name\":"
|
+ "{\"type\":\"minecraft:player\",\"id\":\"00000000-0000-0000-0000-00000000000000\",\"name\":"
|
||||||
+ "{\"text\":\"Name\"}}},\"text\":\"Name\"}]}]}";
|
+ "{\"text\":\"Name\"}}},\"text\":\"Name\"}]}]}";
|
||||||
dissembleReassembleTest.accept( deserializer.apply( json ) );
|
testDissembleReassemble( ComponentSerializer.parse( json ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormatRetentionCopyFormattingCreate()
|
public void testFormatRetentionCopyFormatting()
|
||||||
{
|
|
||||||
this.testFormatRetentionCopyFormatting( () -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Test" ).create() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFormatRetentionCopyFormattingBuild()
|
|
||||||
{
|
|
||||||
this.testFormatRetentionCopyFormatting( () -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "Test" ).build() ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void testFormatRetentionCopyFormatting(Supplier<HoverEvent> hoverEventSupplier)
|
|
||||||
{
|
{
|
||||||
TextComponent first = new TextComponent( "Hello" );
|
TextComponent first = new TextComponent( "Hello" );
|
||||||
first.setBold( true );
|
first.setBold( true );
|
||||||
first.setColor( ChatColor.RED );
|
first.setColor( ChatColor.RED );
|
||||||
first.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "test" ) );
|
first.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "test" ) );
|
||||||
first.setHoverEvent( hoverEventSupplier.get() );
|
first.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Test" ).create() ) );
|
||||||
|
|
||||||
TextComponent second = new TextComponent( " world" );
|
TextComponent second = new TextComponent( " world" );
|
||||||
second.copyFormatting( first, ComponentBuilder.FormatRetention.ALL, true );
|
second.copyFormatting( first, ComponentBuilder.FormatRetention.ALL, true );
|
||||||
@ -352,44 +269,16 @@ public class ComponentsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderCloneCreate()
|
public void testBuilderClone()
|
||||||
{
|
|
||||||
this.testBuilderClone( (builder) -> TextComponent.toLegacyText( builder.create() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilderCloneBuild()
|
|
||||||
{
|
|
||||||
this.testBuilderClone( (builder) -> TextComponent.toLegacyText( builder.build() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void testBuilderClone(Function<ComponentBuilder, String> legacyTextFunction)
|
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.RED ).append( "world" ).color( ChatColor.DARK_RED );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.RED ).append( "world" ).color( ChatColor.DARK_RED );
|
||||||
ComponentBuilder cloned = new ComponentBuilder( builder );
|
ComponentBuilder cloned = new ComponentBuilder( builder );
|
||||||
|
|
||||||
Assert.assertEquals( legacyTextFunction.apply( builder ), legacyTextFunction.apply( cloned ) );
|
Assert.assertEquals( TextComponent.toLegacyText( builder.create() ), TextComponent.toLegacyText( cloned.create() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendCreateMixedComponents()
|
public void testBuilderAppendMixedComponents()
|
||||||
{
|
|
||||||
this.testBuilderAppendMixedComponents(
|
|
||||||
ComponentBuilder::create,
|
|
||||||
(components, index) -> components[index]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilderAppendBuildMixedComponents()
|
|
||||||
{
|
|
||||||
this.testBuilderAppendMixedComponents(
|
|
||||||
ComponentBuilder::build,
|
|
||||||
(component, index) -> component.getExtra().get( index )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilderAppendMixedComponents(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " );
|
||||||
TextComponent textComponent = new TextComponent( "world " );
|
TextComponent textComponent = new TextComponent( "world " );
|
||||||
@ -402,11 +291,11 @@ public class ComponentsTest
|
|||||||
} );
|
} );
|
||||||
ScoreComponent scoreComponent = new ScoreComponent( "myscore", "myobjective" );
|
ScoreComponent scoreComponent = new ScoreComponent( "myscore", "myobjective" );
|
||||||
builder.append( scoreComponent ); // non array based BaseComponent append
|
builder.append( scoreComponent ); // non array based BaseComponent append
|
||||||
T component = componentBuilder.apply( builder );
|
BaseComponent[] components = builder.create();
|
||||||
Assert.assertEquals( "Hello ", extraGetter.apply( component, 0 ).toPlainText() );
|
Assert.assertEquals( "Hello ", components[0].toPlainText() );
|
||||||
Assert.assertEquals( textComponent.toPlainText(), extraGetter.apply( component, 1 ).toPlainText() );
|
Assert.assertEquals( textComponent.toPlainText(), components[1].toPlainText() );
|
||||||
Assert.assertEquals( translatableComponent.toPlainText(), extraGetter.apply( component, 2 ).toPlainText() );
|
Assert.assertEquals( translatableComponent.toPlainText(), components[2].toPlainText() );
|
||||||
Assert.assertEquals( scoreComponent.toPlainText(), extraGetter.apply( component, 3 ).toPlainText() );
|
Assert.assertEquals( scoreComponent.toPlainText(), components[3].toPlainText() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -420,80 +309,32 @@ public class ComponentsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendCreate()
|
public void testBuilderAppend()
|
||||||
{
|
|
||||||
this.testBuilderAppend(
|
|
||||||
() -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Hello world" ).create() ),
|
|
||||||
ComponentBuilder::create,
|
|
||||||
(components, index) -> components[index],
|
|
||||||
BaseComponent::toPlainText,
|
|
||||||
ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
|
||||||
BaseComponent::toLegacyText
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilderAppendBuild()
|
|
||||||
{
|
|
||||||
this.testBuilderAppend(
|
|
||||||
() -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "Hello world" ).build() ) ),
|
|
||||||
ComponentBuilder::build,
|
|
||||||
(component, index) -> component.getExtra().get( index ),
|
|
||||||
(component) -> BaseComponent.toPlainText( component ),
|
|
||||||
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
|
||||||
ChatColor.WHITE.toString() + ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
|
||||||
(component) -> BaseComponent.toLegacyText( component )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilderAppend(Supplier<HoverEvent> hoverEventSupplier, Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter, Function<T, String> toPlainTextFunction, String expectedLegacyText, Function<T, String> toLegacyTextFunction)
|
|
||||||
{
|
{
|
||||||
ClickEvent clickEvent = new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/help " );
|
ClickEvent clickEvent = new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/help " );
|
||||||
HoverEvent hoverEvent = hoverEventSupplier.get();
|
HoverEvent hoverEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Hello world" ).create() );
|
||||||
|
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.YELLOW );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.YELLOW );
|
||||||
builder.append( new ComponentBuilder( "world!" ).color( ChatColor.GREEN ).event( hoverEvent ).event( clickEvent ).create() ); // Intentionally using create() to append multiple individual components
|
builder.append( new ComponentBuilder( "world!" ).color( ChatColor.GREEN ).event( hoverEvent ).event( clickEvent ).create() );
|
||||||
|
|
||||||
T component = componentBuilder.apply( builder );
|
BaseComponent[] components = builder.create();
|
||||||
|
|
||||||
Assert.assertEquals( extraGetter.apply( component, 1 ).getHoverEvent(), hoverEvent );
|
Assert.assertEquals( components[1].getHoverEvent(), hoverEvent );
|
||||||
Assert.assertEquals( extraGetter.apply( component, 1 ).getClickEvent(), clickEvent );
|
Assert.assertEquals( components[1].getClickEvent(), clickEvent );
|
||||||
Assert.assertEquals( "Hello world!", toPlainTextFunction.apply( component ) );
|
Assert.assertEquals( "Hello world!", BaseComponent.toPlainText( components ) );
|
||||||
Assert.assertEquals( expectedLegacyText, toLegacyTextFunction.apply( component ) );
|
Assert.assertEquals( ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!", BaseComponent.toLegacyText( components ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendLegacyCreate()
|
public void testBuilderAppendLegacy()
|
||||||
{
|
|
||||||
this.testBuilderAppendLegacy(
|
|
||||||
ComponentBuilder::create,
|
|
||||||
BaseComponent::toPlainText,
|
|
||||||
ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
|
||||||
BaseComponent::toLegacyText
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilderAppendLegacyBuild()
|
|
||||||
{
|
|
||||||
this.testBuilderAppendLegacy(
|
|
||||||
ComponentBuilder::build,
|
|
||||||
(component) -> BaseComponent.toPlainText( component ),
|
|
||||||
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
|
||||||
ChatColor.WHITE.toString() + ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
|
||||||
(component) -> BaseComponent.toLegacyText( component )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilderAppendLegacy(Function<ComponentBuilder, T> componentBuilder, Function<T, String> toPlainTextFunction, String expectedLegacyString, Function<T, String> toLegacyTextFunction)
|
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.YELLOW );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.YELLOW );
|
||||||
builder.appendLegacy( "§aworld!" );
|
builder.appendLegacy( "§aworld!" );
|
||||||
|
|
||||||
T component = componentBuilder.apply( builder );
|
BaseComponent[] components = builder.create();
|
||||||
|
|
||||||
Assert.assertEquals( "Hello world!", toPlainTextFunction.apply( component ) );
|
Assert.assertEquals( "Hello world!", BaseComponent.toPlainText( components ) );
|
||||||
Assert.assertEquals( expectedLegacyString, toLegacyTextFunction.apply( component ) );
|
Assert.assertEquals( ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!", BaseComponent.toLegacyText( components ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -556,114 +397,57 @@ public class ComponentsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderCreate()
|
public void testBuilder()
|
||||||
{
|
{
|
||||||
this.testBuilder(
|
BaseComponent[] components = new ComponentBuilder( "Hello " ).color( ChatColor.RED ).
|
||||||
ComponentBuilder::create,
|
|
||||||
BaseComponent::toPlainText,
|
|
||||||
ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD
|
|
||||||
+ "World" + ChatColor.YELLOW + ChatColor.BOLD + "!",
|
|
||||||
BaseComponent::toLegacyText
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilderBuild()
|
|
||||||
{
|
|
||||||
this.testBuilder(
|
|
||||||
ComponentBuilder::build,
|
|
||||||
(component) -> BaseComponent.toPlainText( component ),
|
|
||||||
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
|
||||||
ChatColor.WHITE.toString() + ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD
|
|
||||||
+ "World" + ChatColor.YELLOW + ChatColor.BOLD + "!",
|
|
||||||
(component) -> BaseComponent.toLegacyText( component )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilder(Function<ComponentBuilder, T> componentBuilder, Function<T, String> toPlainTextFunction, String expectedLegacyString, Function<T, String> toLegacyTextFunction)
|
|
||||||
{
|
|
||||||
T component = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED ).
|
|
||||||
append( "World" ).bold( true ).color( ChatColor.BLUE ).
|
append( "World" ).bold( true ).color( ChatColor.BLUE ).
|
||||||
append( "!" ).color( ChatColor.YELLOW ) );
|
append( "!" ).color( ChatColor.YELLOW ).create();
|
||||||
|
|
||||||
Assert.assertEquals( "Hello World!", toPlainTextFunction.apply( component ) );
|
Assert.assertEquals( "Hello World!", BaseComponent.toPlainText( components ) );
|
||||||
Assert.assertEquals( expectedLegacyString, toLegacyTextFunction.apply( component ) );
|
Assert.assertEquals( ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD
|
||||||
|
+ "World" + ChatColor.YELLOW + ChatColor.BOLD + "!", BaseComponent.toLegacyText( components ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderCreateReset()
|
public void testBuilderReset()
|
||||||
{
|
{
|
||||||
this.testBuilderReset(
|
BaseComponent[] components = new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
ComponentBuilder::create,
|
.append( "World" ).reset().create();
|
||||||
(components, index) -> components[index]
|
|
||||||
);
|
Assert.assertEquals( components[0].getColor(), ChatColor.RED );
|
||||||
|
Assert.assertEquals( components[1].getColor(), ChatColor.WHITE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderBuildReset()
|
public void testBuilderFormatRetention()
|
||||||
{
|
{
|
||||||
this.testBuilderReset(
|
BaseComponent[] noneRetention = new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
ComponentBuilder::build,
|
.append( "World", ComponentBuilder.FormatRetention.NONE ).create();
|
||||||
(component, index) -> component.getExtra().get( index )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilderReset(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
Assert.assertEquals( noneRetention[0].getColor(), ChatColor.RED );
|
||||||
{
|
Assert.assertEquals( noneRetention[1].getColor(), ChatColor.WHITE );
|
||||||
T component = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
|
||||||
.append( "World" ).reset() );
|
|
||||||
|
|
||||||
Assert.assertEquals( ChatColor.RED, extraGetter.apply( component, 0 ).getColor() );
|
HoverEvent testEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "test" ).create() );
|
||||||
Assert.assertEquals( ChatColor.WHITE, extraGetter.apply( component, 1 ).getColor() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
BaseComponent[] formattingRetention = new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
public void testBuilderCreateFormatRetention()
|
.event( testEvent ).append( "World", ComponentBuilder.FormatRetention.FORMATTING ).create();
|
||||||
{
|
|
||||||
this.testBuilderFormatRetention(
|
|
||||||
ComponentBuilder::create,
|
|
||||||
(components, index) -> components[index]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
Assert.assertEquals( formattingRetention[0].getColor(), ChatColor.RED );
|
||||||
public void testBuilderBuildFormatRetention()
|
Assert.assertEquals( formattingRetention[0].getHoverEvent(), testEvent );
|
||||||
{
|
Assert.assertEquals( formattingRetention[1].getColor(), ChatColor.RED );
|
||||||
this.testBuilderFormatRetention(
|
Assert.assertNull( formattingRetention[1].getHoverEvent() );
|
||||||
ComponentBuilder::build,
|
|
||||||
(component, index) -> component.getExtra().get( index )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilderFormatRetention(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
|
||||||
{
|
|
||||||
T noneRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
|
||||||
.append( "World", ComponentBuilder.FormatRetention.NONE ) );
|
|
||||||
|
|
||||||
Assert.assertEquals( ChatColor.RED, extraGetter.apply( noneRetention, 0 ).getColor() );
|
|
||||||
Assert.assertEquals( ChatColor.WHITE, extraGetter.apply( noneRetention, 1 ).getColor() );
|
|
||||||
|
|
||||||
HoverEvent testEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "test" ).build() ) );
|
|
||||||
|
|
||||||
T formattingRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
|
||||||
.event( testEvent ).append( "World", ComponentBuilder.FormatRetention.FORMATTING ) );
|
|
||||||
|
|
||||||
Assert.assertEquals( ChatColor.RED, extraGetter.apply( formattingRetention, 0 ).getColor() );
|
|
||||||
Assert.assertEquals( testEvent, extraGetter.apply( formattingRetention, 0 ).getHoverEvent() );
|
|
||||||
Assert.assertEquals( ChatColor.RED, extraGetter.apply( formattingRetention, 1 ).getColor() );
|
|
||||||
Assert.assertNull( extraGetter.apply( formattingRetention, 1 ).getHoverEvent() );
|
|
||||||
|
|
||||||
ClickEvent testClickEvent = new ClickEvent( ClickEvent.Action.OPEN_URL, "http://www.example.com" );
|
ClickEvent testClickEvent = new ClickEvent( ClickEvent.Action.OPEN_URL, "http://www.example.com" );
|
||||||
|
|
||||||
T eventRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
BaseComponent[] eventRetention = new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
.event( testEvent ).event( testClickEvent ).append( "World", ComponentBuilder.FormatRetention.EVENTS ) );
|
.event( testEvent ).event( testClickEvent ).append( "World", ComponentBuilder.FormatRetention.EVENTS ).create();
|
||||||
|
|
||||||
Assert.assertEquals( ChatColor.RED, extraGetter.apply( eventRetention, 0 ).getColor() );
|
Assert.assertEquals( eventRetention[0].getColor(), ChatColor.RED );
|
||||||
Assert.assertEquals( testEvent, extraGetter.apply( eventRetention, 0 ).getHoverEvent() );
|
Assert.assertEquals( eventRetention[0].getHoverEvent(), testEvent );
|
||||||
Assert.assertEquals( testClickEvent, extraGetter.apply( eventRetention, 0 ).getClickEvent() );
|
Assert.assertEquals( eventRetention[0].getClickEvent(), testClickEvent );
|
||||||
Assert.assertEquals( ChatColor.WHITE, extraGetter.apply( eventRetention, 1 ).getColor() );
|
Assert.assertEquals( eventRetention[1].getColor(), ChatColor.WHITE );
|
||||||
Assert.assertEquals( testEvent, extraGetter.apply( eventRetention, 1 ).getHoverEvent() );
|
Assert.assertEquals( eventRetention[1].getHoverEvent(), testEvent );
|
||||||
Assert.assertEquals( testClickEvent, extraGetter.apply( eventRetention, 1 ).getClickEvent() );
|
Assert.assertEquals( eventRetention[1].getClickEvent(), testClickEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@ -788,29 +572,12 @@ public class ComponentsTest
|
|||||||
Assert.assertArrayEquals( hexColored, reColored );
|
Assert.assertArrayEquals( hexColored, reColored );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
/**
|
||||||
public void testLegacyResetInBuilderCreate()
|
|
||||||
{
|
|
||||||
this.testLegacyResetInBuilder(
|
|
||||||
ComponentBuilder::create,
|
|
||||||
ComponentSerializer::toString
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLegacyResetInBuilderBuild()
|
|
||||||
{
|
|
||||||
this.testLegacyResetInBuilder(
|
|
||||||
ComponentBuilder::build,
|
|
||||||
ComponentSerializer::toString
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* In legacy chat, colors and reset both reset all formatting.
|
* 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.
|
||||||
*/
|
*/
|
||||||
private <T> void testLegacyResetInBuilder(Function<ComponentBuilder, T> componentBuilder, Function<T, String> componentSerializer)
|
@Test
|
||||||
|
public void testLegacyResetInBuilder()
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder();
|
ComponentBuilder builder = new ComponentBuilder();
|
||||||
BaseComponent[] a = TextComponent.fromLegacyText( "§4§n44444§rdd§6§l6666" );
|
BaseComponent[] a = TextComponent.fromLegacyText( "§4§n44444§rdd§6§l6666" );
|
||||||
@ -821,13 +588,13 @@ public class ComponentsTest
|
|||||||
|
|
||||||
builder.append( a );
|
builder.append( a );
|
||||||
|
|
||||||
String test1 = componentSerializer.apply( componentBuilder.apply( builder ) );
|
String test1 = ComponentSerializer.toString( builder.create() );
|
||||||
Assert.assertEquals( expected, test1 );
|
Assert.assertEquals( expected, test1 );
|
||||||
|
|
||||||
BaseComponent[] b = TextComponent.fromLegacyText( "§rrrrr" );
|
BaseComponent[] b = TextComponent.fromLegacyText( "§rrrrr" );
|
||||||
builder.append( b );
|
builder.append( b );
|
||||||
|
|
||||||
String test2 = componentSerializer.apply( componentBuilder.apply( builder ) );
|
String test2 = ComponentSerializer.toString( builder.create() );
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
"{\"extra\":[{\"underlined\":true,\"color\":\"dark_red\",\"text\":\"44444\"},"
|
"{\"extra\":[{\"underlined\":true,\"color\":\"dark_red\",\"text\":\"44444\"},"
|
||||||
+ "{\"color\":\"white\",\"text\":\"dd\"},{\"bold\":true,\"color\":\"gold\",\"text\":\"6666\"},"
|
+ "{\"color\":\"white\",\"text\":\"dd\"},{\"bold\":true,\"color\":\"gold\",\"text\":\"6666\"},"
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-config</artifactId>
|
<artifactId>bungeecord-config</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Config</name>
|
<name>BungeeCord-Config</name>
|
||||||
@ -22,14 +22,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.10.1</version>
|
<version>2.10</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
<version>2.2</version>
|
<version>2.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-event</artifactId>
|
<artifactId>bungeecord-event</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-log</artifactId>
|
<artifactId>bungeecord-log</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-cmd-alert</artifactId>
|
<artifactId>bungeecord-module-cmd-alert</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-cmd-find</artifactId>
|
<artifactId>bungeecord-module-cmd-find</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_find</name>
|
<name>cmd_find</name>
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
package net.md_5.bungee.module.cmd.find;
|
package net.md_5.bungee.module.cmd.find;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.command.PlayerCommand;
|
import net.md_5.bungee.command.PlayerCommand;
|
||||||
|
|
||||||
@ -32,27 +27,8 @@ public class CommandFind extends PlayerCommand
|
|||||||
sender.sendMessage( ProxyServer.getInstance().getTranslation( "user_not_online" ) );
|
sender.sendMessage( ProxyServer.getInstance().getTranslation( "user_not_online" ) );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
boolean moduleLoaded = ProxyServer.getInstance().getPluginManager().getPlugin( "cmd_server" ) != null;
|
sender.sendMessage( ProxyServer.getInstance().getTranslation( "user_online_at", player.getName(), player.getServer().getInfo().getName() ) );
|
||||||
ServerInfo server = player.getServer().getInfo();
|
|
||||||
ComponentBuilder componentBuilder = new ComponentBuilder().appendLegacy( ProxyServer.getInstance().getTranslation( "user_online_at", player.getName(), server.getName() ) );
|
|
||||||
|
|
||||||
if ( moduleLoaded && server.canAccess( sender ) )
|
|
||||||
{
|
|
||||||
componentBuilder.event( new HoverEvent(
|
|
||||||
HoverEvent.Action.SHOW_TEXT,
|
|
||||||
new ComponentBuilder().appendLegacy( ProxyServer.getInstance().getTranslation( "click_to_connect" ) ).create() )
|
|
||||||
);
|
|
||||||
componentBuilder.event( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/server " + server.getName() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage( componentBuilder.create() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args)
|
|
||||||
{
|
|
||||||
return args.length == 1 ? super.onTabComplete( sender, args ) : Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module</artifactId>
|
<artifactId>bungeecord-module</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-cmd-list</artifactId>
|
<artifactId>bungeecord-module-cmd-list</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-cmd-send</artifactId>
|
<artifactId>bungeecord-module-cmd-send</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_send</name>
|
<name>cmd_send</name>
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module</artifactId>
|
<artifactId>bungeecord-module</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-cmd-server</artifactId>
|
<artifactId>bungeecord-module-cmd-server</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_server</name>
|
<name>cmd_server</name>
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module</artifactId>
|
<artifactId>bungeecord-module</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-reconnect-yaml</artifactId>
|
<artifactId>bungeecord-module-reconnect-yaml</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-native</artifactId>
|
<artifactId>bungeecord-native</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Native</name>
|
<name>BungeeCord-Native</name>
|
||||||
|
24
pom.xml
24
pom.xml
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Parent</name>
|
<name>BungeeCord-Parent</name>
|
||||||
@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<build.number>unknown</build.number>
|
<build.number>unknown</build.number>
|
||||||
<lombok.version>1.18.30</lombok.version>
|
<lombok.version>1.18.28</lombok.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
@ -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.97.Final</version>
|
<version>4.1.93.Final</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -99,7 +99,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>32.1.2-jre</version>
|
<version>31.1-jre</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -117,20 +117,11 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>3.6.0</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>scriptus</artifactId>
|
<artifactId>scriptus</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>0.4.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<format>git:${project.name}:${project.version}:%s:${build.number}</format>
|
<format>git:${project.name}:${project.version}:%s:${build.number}</format>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -196,7 +187,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-enforcer-plugin</artifactId>
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
<version>3.4.1</version>
|
<version>3.3.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>enforce</id>
|
<id>enforce</id>
|
||||||
@ -213,7 +204,7 @@
|
|||||||
</rules>
|
</rules>
|
||||||
</configuration>
|
</configuration>
|
||||||
<goals>
|
<goals>
|
||||||
<!--<goal>enforce</goal>--> <!-- Disabled until maven-resolver is upgraded again. -->
|
<goal>enforce</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@ -314,6 +305,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.5.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<!-- Execute Javadoc once normally to catch any warnings -->
|
<!-- Execute Javadoc once normally to catch any warnings -->
|
||||||
<execution>
|
<execution>
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-protocol</artifactId>
|
<artifactId>bungeecord-protocol</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Protocol</name>
|
<name>BungeeCord-Protocol</name>
|
||||||
|
@ -11,7 +11,6 @@ import net.md_5.bungee.protocol.packet.Commands;
|
|||||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||||
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
||||||
import net.md_5.bungee.protocol.packet.EntityStatus;
|
import net.md_5.bungee.protocol.packet.EntityStatus;
|
||||||
import net.md_5.bungee.protocol.packet.FinishConfiguration;
|
|
||||||
import net.md_5.bungee.protocol.packet.GameState;
|
import net.md_5.bungee.protocol.packet.GameState;
|
||||||
import net.md_5.bungee.protocol.packet.Handshake;
|
import net.md_5.bungee.protocol.packet.Handshake;
|
||||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||||
@ -19,7 +18,6 @@ import net.md_5.bungee.protocol.packet.Kick;
|
|||||||
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
||||||
import net.md_5.bungee.protocol.packet.LegacyPing;
|
import net.md_5.bungee.protocol.packet.LegacyPing;
|
||||||
import net.md_5.bungee.protocol.packet.Login;
|
import net.md_5.bungee.protocol.packet.Login;
|
||||||
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
|
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||||
@ -36,7 +34,6 @@ import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
|||||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||||
import net.md_5.bungee.protocol.packet.ServerData;
|
import net.md_5.bungee.protocol.packet.ServerData;
|
||||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
|
||||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||||
import net.md_5.bungee.protocol.packet.Subtitle;
|
import net.md_5.bungee.protocol.packet.Subtitle;
|
||||||
@ -226,16 +223,4 @@ public abstract class AbstractPacketHandler
|
|||||||
public void handle(ServerData serverData) throws Exception
|
public void handle(ServerData serverData) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(LoginAcknowledged loginAcknowledged) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(StartConfiguration startConfiguration) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(FinishConfiguration finishConfiguration) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,7 @@ import java.util.EnumSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import se.llbit.nbt.ErrorTag;
|
|
||||||
import se.llbit.nbt.NamedTag;
|
import se.llbit.nbt.NamedTag;
|
||||||
import se.llbit.nbt.SpecificTag;
|
|
||||||
import se.llbit.nbt.Tag;
|
import se.llbit.nbt.Tag;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ -295,35 +293,14 @@ public abstract class DefinedPacket
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Tag readTag(ByteBuf input, int protocolVersion)
|
public static Tag readTag(ByteBuf input)
|
||||||
{
|
{
|
||||||
DataInputStream in = new DataInputStream( new ByteBufInputStream( input ) );
|
Tag tag = NamedTag.read( new DataInputStream( new ByteBufInputStream( input ) ) );
|
||||||
Tag tag;
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
byte type = in.readByte();
|
|
||||||
if ( type == 0 )
|
|
||||||
{
|
|
||||||
return Tag.END;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
tag = SpecificTag.read( type, in );
|
|
||||||
}
|
|
||||||
} catch ( IOException ex )
|
|
||||||
{
|
|
||||||
tag = new ErrorTag( "IOException while reading tag type:\n" + ex.getMessage() );
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
tag = NamedTag.read( in );
|
|
||||||
}
|
|
||||||
Preconditions.checkArgument( !tag.isError(), "Error reading tag: %s", tag.error() );
|
Preconditions.checkArgument( !tag.isError(), "Error reading tag: %s", tag.error() );
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeTag(Tag tag, ByteBuf output, int protocolVersion)
|
public static void writeTag(Tag tag, ByteBuf output)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -401,11 +378,6 @@ public abstract class DefinedPacket
|
|||||||
write( buf );
|
write( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Protocol nextProtocol()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void handle(AbstractPacketHandler handler) throws Exception;
|
public abstract void handle(AbstractPacketHandler handler) throws Exception;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,14 +5,12 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
private Protocol protocol;
|
private Protocol protocol;
|
||||||
private final boolean server;
|
private final boolean server;
|
||||||
|
@ -4,14 +4,12 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.MessageToByteEncoder;
|
import io.netty.handler.codec.MessageToByteEncoder;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class MinecraftEncoder extends MessageToByteEncoder<DefinedPacket>
|
public class MinecraftEncoder extends MessageToByteEncoder<DefinedPacket>
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
private Protocol protocol;
|
private Protocol protocol;
|
||||||
private boolean server;
|
private boolean server;
|
||||||
|
@ -19,13 +19,11 @@ import net.md_5.bungee.protocol.packet.Commands;
|
|||||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||||
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
||||||
import net.md_5.bungee.protocol.packet.EntityStatus;
|
import net.md_5.bungee.protocol.packet.EntityStatus;
|
||||||
import net.md_5.bungee.protocol.packet.FinishConfiguration;
|
|
||||||
import net.md_5.bungee.protocol.packet.GameState;
|
import net.md_5.bungee.protocol.packet.GameState;
|
||||||
import net.md_5.bungee.protocol.packet.Handshake;
|
import net.md_5.bungee.protocol.packet.Handshake;
|
||||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||||
import net.md_5.bungee.protocol.packet.Kick;
|
import net.md_5.bungee.protocol.packet.Kick;
|
||||||
import net.md_5.bungee.protocol.packet.Login;
|
import net.md_5.bungee.protocol.packet.Login;
|
||||||
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
|
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||||
@ -42,7 +40,6 @@ import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
|||||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||||
import net.md_5.bungee.protocol.packet.ServerData;
|
import net.md_5.bungee.protocol.packet.ServerData;
|
||||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
|
||||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||||
import net.md_5.bungee.protocol.packet.Subtitle;
|
import net.md_5.bungee.protocol.packet.Subtitle;
|
||||||
@ -88,8 +85,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x1E ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x1E ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Login.class,
|
Login.class,
|
||||||
@ -104,8 +100,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x23 ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x23 ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket( Chat.class,
|
TO_CLIENT.registerPacket( Chat.class,
|
||||||
Chat::new,
|
Chat::new,
|
||||||
@ -133,8 +128,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x3B ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x3B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x3E ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x3E ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
BossBar.class,
|
BossBar.class,
|
||||||
@ -144,8 +138,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x0C ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x0C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x0D ),
|
map( ProtocolConstants.MINECRAFT_1_17, 0x0D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x0A ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x0A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0B ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0xB )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0A )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PlayerListItem.class, // PlayerInfo
|
PlayerListItem.class, // PlayerInfo
|
||||||
@ -175,8 +168,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x11 ),
|
map( ProtocolConstants.MINECRAFT_1_17, 0x11 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x0E ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x0E ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0D ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0F ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0xF )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x10 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ScoreboardObjective.class,
|
ScoreboardObjective.class,
|
||||||
@ -191,8 +183,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x53 ),
|
map( ProtocolConstants.MINECRAFT_1_17, 0x53 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x56 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x56 ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ScoreboardScore.class,
|
ScoreboardScore.class,
|
||||||
@ -207,8 +198,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x56 ),
|
map( ProtocolConstants.MINECRAFT_1_17, 0x56 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x59 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x59 ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ScoreboardDisplay.class,
|
ScoreboardDisplay.class,
|
||||||
@ -223,8 +213,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x4C ),
|
map( ProtocolConstants.MINECRAFT_1_17, 0x4C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4F ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4F ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Team.class,
|
Team.class,
|
||||||
@ -239,8 +228,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x55 ),
|
map( ProtocolConstants.MINECRAFT_1_17, 0x55 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x58 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x58 ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PluginMessage.class,
|
PluginMessage.class,
|
||||||
@ -256,8 +244,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x15 ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x15 ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Kick.class,
|
Kick.class,
|
||||||
@ -273,8 +260,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x17 ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x17 ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Title.class,
|
Title.class,
|
||||||
@ -290,8 +276,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_18, 0x5A ),
|
map( ProtocolConstants.MINECRAFT_1_18, 0x5A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5D ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5D ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ClearTitles.class,
|
ClearTitles.class,
|
||||||
@ -299,8 +284,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x10 ),
|
map( ProtocolConstants.MINECRAFT_1_17, 0x10 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x0D ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x0D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0C ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0E ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0xE )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Subtitle.class,
|
Subtitle.class,
|
||||||
@ -309,8 +293,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_18, 0x58 ),
|
map( ProtocolConstants.MINECRAFT_1_18, 0x58 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5B ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5B ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
TitleTimes.class,
|
TitleTimes.class,
|
||||||
@ -319,8 +302,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_18, 0x5B ),
|
map( ProtocolConstants.MINECRAFT_1_18, 0x5B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5E ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5E ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
SystemChat.class,
|
SystemChat.class,
|
||||||
@ -328,8 +310,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x5F ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x5F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x62 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x62 ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PlayerListHeaderFooter.class,
|
PlayerListHeaderFooter.class,
|
||||||
@ -348,8 +329,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x60 ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x60 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x63 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x63 ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
EntityStatus.class,
|
EntityStatus.class,
|
||||||
@ -365,8 +345,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x18 ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x18 ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Commands.class,
|
Commands.class,
|
||||||
@ -378,8 +357,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x12 ),
|
map( ProtocolConstants.MINECRAFT_1_17, 0x12 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x0F ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x0F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0E ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0E ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x10 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x10 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x11 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
GameState.class,
|
GameState.class,
|
||||||
@ -391,8 +369,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x1B ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x1B ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ViewDistance.class,
|
ViewDistance.class,
|
||||||
@ -404,8 +381,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x49 ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x49 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4C ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4C ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ServerData.class,
|
ServerData.class,
|
||||||
@ -413,27 +389,19 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x3F ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x3F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x42 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x42 ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
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 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
StartConfiguration.class,
|
|
||||||
StartConfiguration::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x65 )
|
|
||||||
);
|
);
|
||||||
|
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
@ -450,8 +418,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x11 ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x11 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x12 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x12 ),
|
||||||
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 )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket( Chat.class,
|
TO_SERVER.registerPacket( Chat.class,
|
||||||
Chat::new,
|
Chat::new,
|
||||||
@ -486,8 +453,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x08 ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x08 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x09 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x09 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x08 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x08 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x09 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x09 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0A )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
ClientSettings.class,
|
ClientSettings.class,
|
||||||
@ -500,8 +466,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x07 ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x07 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x08 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x08 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x07 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x07 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x08 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x08 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x09 )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
PluginMessage.class,
|
PluginMessage.class,
|
||||||
@ -516,13 +481,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x0C ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x0C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x0D ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x0D ),
|
||||||
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 )
|
|
||||||
);
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
StartConfiguration.class,
|
|
||||||
StartConfiguration::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0B )
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -600,59 +559,6 @@ public enum Protocol
|
|||||||
LoginPayloadResponse::new,
|
LoginPayloadResponse::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x02 )
|
map( ProtocolConstants.MINECRAFT_1_13, 0x02 )
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
LoginAcknowledged.class,
|
|
||||||
LoginAcknowledged::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 3
|
|
||||||
CONFIGURATION
|
|
||||||
{
|
|
||||||
|
|
||||||
{
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
PluginMessage.class,
|
|
||||||
PluginMessage::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x00 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
Kick.class,
|
|
||||||
Kick::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
FinishConfiguration.class,
|
|
||||||
FinishConfiguration::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
KeepAlive.class,
|
|
||||||
KeepAlive::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 )
|
|
||||||
);
|
|
||||||
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
ClientSettings.class,
|
|
||||||
ClientSettings::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x00 )
|
|
||||||
);
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
PluginMessage.class,
|
|
||||||
PluginMessage::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 )
|
|
||||||
);
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
FinishConfiguration.class,
|
|
||||||
FinishConfiguration::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 )
|
|
||||||
);
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
KeepAlive.class,
|
|
||||||
KeepAlive::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
|
@ -43,7 +43,6 @@ public class ProtocolConstants
|
|||||||
public static final int MINECRAFT_1_19_3 = 761;
|
public static final int MINECRAFT_1_19_3 = 761;
|
||||||
public static final int MINECRAFT_1_19_4 = 762;
|
public static final int MINECRAFT_1_19_4 = 762;
|
||||||
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 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;
|
||||||
|
|
||||||
@ -100,14 +99,13 @@ public class ProtocolConstants
|
|||||||
ProtocolConstants.MINECRAFT_1_19_1,
|
ProtocolConstants.MINECRAFT_1_19_1,
|
||||||
ProtocolConstants.MINECRAFT_1_19_3,
|
ProtocolConstants.MINECRAFT_1_19_3,
|
||||||
ProtocolConstants.MINECRAFT_1_19_4,
|
ProtocolConstants.MINECRAFT_1_19_4,
|
||||||
ProtocolConstants.MINECRAFT_1_20,
|
ProtocolConstants.MINECRAFT_1_20
|
||||||
ProtocolConstants.MINECRAFT_1_20_2
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( SNAPSHOT_SUPPORT )
|
if ( SNAPSHOT_SUPPORT )
|
||||||
{
|
{
|
||||||
// supportedVersions.add( "1.20.x" );
|
// supportedVersions.add( "1.20.x" );
|
||||||
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20_2 );
|
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20 );
|
||||||
}
|
}
|
||||||
|
|
||||||
SUPPORTED_VERSIONS = supportedVersions.build();
|
SUPPORTED_VERSIONS = supportedVersions.build();
|
||||||
|
@ -32,7 +32,7 @@ public class ClientCommand extends DefinedPacket
|
|||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
{
|
{
|
||||||
command = readString( buf, 256 );
|
command = readString( buf );
|
||||||
timestamp = buf.readLong();
|
timestamp = buf.readLong();
|
||||||
salt = buf.readLong();
|
salt = buf.readLong();
|
||||||
|
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.Protocol;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class FinishConfiguration extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Protocol nextProtocol()
|
|
||||||
{
|
|
||||||
return Protocol.GAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -36,7 +36,6 @@ public class Login extends DefinedPacket
|
|||||||
private int simulationDistance;
|
private int simulationDistance;
|
||||||
private boolean reducedDebugInfo;
|
private boolean reducedDebugInfo;
|
||||||
private boolean normalRespawn;
|
private boolean normalRespawn;
|
||||||
private boolean limitedCrafting;
|
|
||||||
private boolean debug;
|
private boolean debug;
|
||||||
private boolean flat;
|
private boolean flat;
|
||||||
private Location deathLocation;
|
private Location deathLocation;
|
||||||
@ -50,16 +49,10 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
hardcore = buf.readBoolean();
|
hardcore = buf.readBoolean();
|
||||||
}
|
}
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
gameMode = buf.readUnsignedByte();
|
||||||
{
|
|
||||||
gameMode = buf.readUnsignedByte();
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
previousGameMode = buf.readUnsignedByte();
|
||||||
{
|
|
||||||
previousGameMode = buf.readUnsignedByte();
|
|
||||||
}
|
|
||||||
|
|
||||||
worldNames = new HashSet<>();
|
worldNames = new HashSet<>();
|
||||||
int worldCount = readVarInt( buf );
|
int worldCount = readVarInt( buf );
|
||||||
@ -68,25 +61,19 @@ public class Login extends DefinedPacket
|
|||||||
worldNames.add( readString( buf ) );
|
worldNames.add( readString( buf ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
dimensions = readTag( buf );
|
||||||
{
|
|
||||||
dimensions = readTag( buf, protocolVersion );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 )
|
||||||
{
|
{
|
||||||
dimension = readTag( buf, protocolVersion );
|
dimension = readTag( buf );
|
||||||
} else if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
} else
|
||||||
{
|
{
|
||||||
dimension = readString( buf );
|
dimension = readString( buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
worldName = readString( buf );
|
||||||
{
|
|
||||||
worldName = readString( buf );
|
|
||||||
}
|
|
||||||
} else if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 )
|
} else if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 )
|
||||||
{
|
{
|
||||||
dimension = buf.readInt();
|
dimension = buf.readInt();
|
||||||
@ -94,7 +81,7 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
dimension = (int) buf.readByte();
|
dimension = (int) buf.readByte();
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 && protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 )
|
||||||
{
|
{
|
||||||
seed = buf.readLong();
|
seed = buf.readLong();
|
||||||
}
|
}
|
||||||
@ -129,15 +116,6 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
normalRespawn = buf.readBoolean();
|
normalRespawn = buf.readBoolean();
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
|
||||||
{
|
|
||||||
limitedCrafting = buf.readBoolean();
|
|
||||||
dimension = readString( buf );
|
|
||||||
worldName = readString( buf );
|
|
||||||
seed = buf.readLong();
|
|
||||||
gameMode = buf.readUnsignedByte();
|
|
||||||
previousGameMode = buf.readByte();
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
debug = buf.readBoolean();
|
debug = buf.readBoolean();
|
||||||
@ -164,16 +142,10 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
buf.writeBoolean( hardcore );
|
buf.writeBoolean( hardcore );
|
||||||
}
|
}
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
buf.writeByte( gameMode );
|
||||||
{
|
|
||||||
buf.writeByte( gameMode );
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
buf.writeByte( previousGameMode );
|
||||||
{
|
|
||||||
buf.writeByte( previousGameMode );
|
|
||||||
}
|
|
||||||
|
|
||||||
writeVarInt( worldNames.size(), buf );
|
writeVarInt( worldNames.size(), buf );
|
||||||
for ( String world : worldNames )
|
for ( String world : worldNames )
|
||||||
@ -181,25 +153,19 @@ public class Login extends DefinedPacket
|
|||||||
writeString( world, buf );
|
writeString( world, buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
writeTag( dimensions, buf );
|
||||||
{
|
|
||||||
writeTag( dimensions, buf, protocolVersion );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 )
|
||||||
{
|
{
|
||||||
writeTag( (Tag) dimension, buf, protocolVersion );
|
writeTag( (Tag) dimension, buf );
|
||||||
} else if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
} else
|
||||||
{
|
{
|
||||||
writeString( (String) dimension, buf );
|
writeString( (String) dimension, buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
writeString( worldName, buf );
|
||||||
{
|
|
||||||
writeString( worldName, buf );
|
|
||||||
}
|
|
||||||
} else if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 )
|
} else if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 )
|
||||||
{
|
{
|
||||||
buf.writeInt( (Integer) dimension );
|
buf.writeInt( (Integer) dimension );
|
||||||
@ -209,10 +175,7 @@ public class Login extends DefinedPacket
|
|||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
buf.writeLong( seed );
|
||||||
{
|
|
||||||
buf.writeLong( seed );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_14 )
|
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_14 )
|
||||||
{
|
{
|
||||||
@ -245,15 +208,6 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
buf.writeBoolean( normalRespawn );
|
buf.writeBoolean( normalRespawn );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( limitedCrafting );
|
|
||||||
writeString( (String) dimension, buf );
|
|
||||||
writeString( worldName, buf );
|
|
||||||
buf.writeLong( seed );
|
|
||||||
buf.writeByte( gameMode );
|
|
||||||
buf.writeByte( previousGameMode );
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
buf.writeBoolean( debug );
|
buf.writeBoolean( debug );
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.Protocol;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class LoginAcknowledged extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Protocol nextProtocol()
|
|
||||||
{
|
|
||||||
return Protocol.CONFIGURATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -32,7 +32,7 @@ public class LoginRequest extends DefinedPacket
|
|||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 || buf.readBoolean() )
|
if ( buf.readBoolean() )
|
||||||
{
|
{
|
||||||
uuid = readUUID( buf );
|
uuid = readUUID( buf );
|
||||||
}
|
}
|
||||||
@ -49,19 +49,13 @@ public class LoginRequest extends DefinedPacket
|
|||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
if ( uuid != null )
|
||||||
{
|
{
|
||||||
|
buf.writeBoolean( true );
|
||||||
writeUUID( uuid, buf );
|
writeUUID( uuid, buf );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if ( uuid != null )
|
buf.writeBoolean( false );
|
||||||
{
|
|
||||||
buf.writeBoolean( true );
|
|
||||||
writeUUID( uuid, buf );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
buf.writeBoolean( false );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class Respawn extends DefinedPacket
|
|||||||
private String levelType;
|
private String levelType;
|
||||||
private boolean debug;
|
private boolean debug;
|
||||||
private boolean flat;
|
private boolean flat;
|
||||||
private byte copyMeta;
|
private boolean copyMeta;
|
||||||
private Location deathLocation;
|
private Location deathLocation;
|
||||||
private int portalCooldown;
|
private int portalCooldown;
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ public class Respawn extends DefinedPacket
|
|||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 )
|
||||||
{
|
{
|
||||||
dimension = readTag( buf, protocolVersion );
|
dimension = readTag( buf );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
dimension = readString( buf );
|
dimension = readString( buf );
|
||||||
@ -62,10 +62,7 @@ public class Respawn extends DefinedPacket
|
|||||||
previousGameMode = buf.readUnsignedByte();
|
previousGameMode = buf.readUnsignedByte();
|
||||||
debug = buf.readBoolean();
|
debug = buf.readBoolean();
|
||||||
flat = buf.readBoolean();
|
flat = buf.readBoolean();
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
copyMeta = buf.readBoolean();
|
||||||
{
|
|
||||||
copyMeta = buf.readByte();
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
levelType = readString( buf );
|
levelType = readString( buf );
|
||||||
@ -81,10 +78,6 @@ public class Respawn extends DefinedPacket
|
|||||||
{
|
{
|
||||||
portalCooldown = readVarInt( buf );
|
portalCooldown = readVarInt( buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
|
||||||
{
|
|
||||||
copyMeta = buf.readByte();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -94,7 +87,7 @@ public class Respawn extends DefinedPacket
|
|||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 )
|
||||||
{
|
{
|
||||||
writeTag( (Tag) dimension, buf, protocolVersion );
|
writeTag( (Tag) dimension, buf );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
writeString( (String) dimension, buf );
|
writeString( (String) dimension, buf );
|
||||||
@ -118,10 +111,7 @@ public class Respawn extends DefinedPacket
|
|||||||
buf.writeByte( previousGameMode );
|
buf.writeByte( previousGameMode );
|
||||||
buf.writeBoolean( debug );
|
buf.writeBoolean( debug );
|
||||||
buf.writeBoolean( flat );
|
buf.writeBoolean( flat );
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
buf.writeBoolean( copyMeta );
|
||||||
{
|
|
||||||
buf.writeByte( copyMeta );
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
writeString( levelType, buf );
|
writeString( levelType, buf );
|
||||||
@ -142,10 +132,6 @@ public class Respawn extends DefinedPacket
|
|||||||
{
|
{
|
||||||
writeVarInt( portalCooldown, buf );
|
writeVarInt( portalCooldown, buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
|
||||||
{
|
|
||||||
buf.writeByte( copyMeta );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,7 +7,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@ -19,32 +18,20 @@ public class ScoreboardDisplay extends DefinedPacket
|
|||||||
/**
|
/**
|
||||||
* 0 = list, 1 = side, 2 = below.
|
* 0 = list, 1 = side, 2 = below.
|
||||||
*/
|
*/
|
||||||
private int position;
|
private byte position;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
position = buf.readByte();
|
||||||
{
|
|
||||||
position = readVarInt( buf );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
position = buf.readByte();
|
|
||||||
}
|
|
||||||
name = readString( buf );
|
name = readString( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void write(ByteBuf buf)
|
||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
buf.writeByte( position );
|
||||||
{
|
|
||||||
writeVarInt( position, buf );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
buf.writeByte( position );
|
|
||||||
}
|
|
||||||
writeString( name, buf );
|
writeString( name, buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.Protocol;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class StartConfiguration extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Protocol nextProtocol()
|
|
||||||
{
|
|
||||||
return Protocol.CONFIGURATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.1.0</version>
|
<version>8.0.33</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.8.5</version>
|
<version>3.9.2</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.7.3</version>
|
<version>1.9.10</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.7.3</version>
|
<version>1.9.10</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -103,30 +103,26 @@ public class BungeeServerInfo implements ServerInfo
|
|||||||
sendData( channel, data, true );
|
sendData( channel, data, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Don't like this method
|
||||||
@Override
|
@Override
|
||||||
public boolean sendData(String channel, byte[] data, boolean queue)
|
public boolean sendData(String channel, byte[] data, boolean queue)
|
||||||
{
|
{
|
||||||
Preconditions.checkNotNull( channel, "channel" );
|
Preconditions.checkNotNull( channel, "channel" );
|
||||||
Preconditions.checkNotNull( data, "data" );
|
Preconditions.checkNotNull( data, "data" );
|
||||||
|
|
||||||
Server server;
|
synchronized ( packetQueue )
|
||||||
synchronized ( players )
|
|
||||||
{
|
{
|
||||||
server = ( players.isEmpty() ) ? null : players.iterator().next().getServer();
|
Server server = ( players.isEmpty() ) ? null : players.iterator().next().getServer();
|
||||||
}
|
if ( server != null )
|
||||||
|
{
|
||||||
if ( server != null )
|
server.sendData( channel, data );
|
||||||
{
|
return true;
|
||||||
server.sendData( channel, data );
|
} else if ( queue )
|
||||||
return true;
|
|
||||||
} else if ( queue )
|
|
||||||
{
|
|
||||||
synchronized ( packetQueue )
|
|
||||||
{
|
{
|
||||||
packetQueue.add( new PluginMessage( channel, data, false ) );
|
packetQueue.add( new PluginMessage( channel, data, false ) );
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long lastPing;
|
private long lastPing;
|
||||||
|
@ -43,7 +43,6 @@ import net.md_5.bungee.protocol.packet.GameState;
|
|||||||
import net.md_5.bungee.protocol.packet.Handshake;
|
import net.md_5.bungee.protocol.packet.Handshake;
|
||||||
import net.md_5.bungee.protocol.packet.Kick;
|
import net.md_5.bungee.protocol.packet.Kick;
|
||||||
import net.md_5.bungee.protocol.packet.Login;
|
import net.md_5.bungee.protocol.packet.Login;
|
||||||
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
|
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||||
@ -53,7 +52,6 @@ import net.md_5.bungee.protocol.packet.Respawn;
|
|||||||
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
|
||||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||||
import net.md_5.bungee.util.AddressUtil;
|
import net.md_5.bungee.util.AddressUtil;
|
||||||
import net.md_5.bungee.util.BufUtil;
|
import net.md_5.bungee.util.BufUtil;
|
||||||
@ -75,7 +73,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
private enum State
|
private enum State
|
||||||
{
|
{
|
||||||
|
|
||||||
LOGIN_SUCCESS, LOGIN, FINISHED;
|
LOGIN_SUCCESS, ENCRYPT_RESPONSE, LOGIN, FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,13 +84,13 @@ public class ServerConnector extends PacketHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String message = ChatColor.RED + "Exception Connecting: " + Util.exception( t );
|
String message = "Exception Connecting:" + Util.exception( t );
|
||||||
if ( user.getServer() == null )
|
if ( user.getServer() == null )
|
||||||
{
|
{
|
||||||
user.disconnect( message );
|
user.disconnect( message );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
user.sendMessage( message );
|
user.sendMessage( ChatColor.RED + message );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,15 +145,8 @@ public class ServerConnector extends PacketHandler
|
|||||||
public void handle(LoginSuccess loginSuccess) throws Exception
|
public void handle(LoginSuccess loginSuccess) throws Exception
|
||||||
{
|
{
|
||||||
Preconditions.checkState( thisState == State.LOGIN_SUCCESS, "Not expecting LOGIN_SUCCESS" );
|
Preconditions.checkState( thisState == State.LOGIN_SUCCESS, "Not expecting LOGIN_SUCCESS" );
|
||||||
if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_20_2 )
|
ch.setProtocol( Protocol.GAME );
|
||||||
{
|
thisState = State.LOGIN;
|
||||||
ServerConnection server = new ServerConnection( ch, target );
|
|
||||||
cutThrough( server );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
ch.setProtocol( Protocol.GAME );
|
|
||||||
thisState = State.LOGIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only reset the Forge client when:
|
// Only reset the Forge client when:
|
||||||
// 1) The user is switching servers (so has a current server)
|
// 1) The user is switching servers (so has a current server)
|
||||||
@ -191,12 +182,6 @@ public class ServerConnector extends PacketHandler
|
|||||||
Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" );
|
Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" );
|
||||||
|
|
||||||
ServerConnection server = new ServerConnection( ch, target );
|
ServerConnection server = new ServerConnection( ch, target );
|
||||||
handleLogin( bungee, ch, user, target, handshakeHandler, server, login );
|
|
||||||
cutThrough( server );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void handleLogin(ProxyServer bungee, ChannelWrapper ch, UserConnection user, BungeeServerInfo target, ForgeServerHandler handshakeHandler, ServerConnection server, Login login) throws Exception
|
|
||||||
{
|
|
||||||
ServerConnectedEvent event = new ServerConnectedEvent( user, server );
|
ServerConnectedEvent event = new ServerConnectedEvent( user, server );
|
||||||
bungee.getPluginManager().callEvent( event );
|
bungee.getPluginManager().callEvent( event );
|
||||||
|
|
||||||
@ -240,13 +225,14 @@ 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.isDebug(), login.isFlat(), login.getDeathLocation(),
|
||||||
login.getPortalCooldown() );
|
login.getPortalCooldown() );
|
||||||
|
|
||||||
user.unsafe().sendPacket( modLogin );
|
user.unsafe().sendPacket( modLogin );
|
||||||
|
|
||||||
if ( user.getDimension() != null )
|
if ( user.getServer() != null )
|
||||||
{
|
{
|
||||||
|
user.getServer().setObsolete( true );
|
||||||
user.getTabListHandler().onServerChange();
|
user.getTabListHandler().onServerChange();
|
||||||
|
|
||||||
user.getServerSentScoreboard().clear();
|
user.getServerSentScoreboard().clear();
|
||||||
@ -258,15 +244,14 @@ public class ServerConnector extends PacketHandler
|
|||||||
}
|
}
|
||||||
user.getSentBossBars().clear();
|
user.getSentBossBars().clear();
|
||||||
|
|
||||||
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), (byte) 0, login.getDeathLocation(),
|
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), false, login.getDeathLocation(),
|
||||||
login.getPortalCooldown() ) );
|
login.getPortalCooldown() ) );
|
||||||
|
user.getServer().disconnect( "Quitting" );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
user.unsafe().sendPacket( BungeeCord.getInstance().registerChannels( user.getPendingConnection().getVersion() ) );
|
|
||||||
|
|
||||||
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||||
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
||||||
user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler != null && handshakeHandler.isServerForge() ) );
|
user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler.isServerForge() ) );
|
||||||
brand.release();
|
brand.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,40 +295,19 @@ public class ServerConnector extends PacketHandler
|
|||||||
if ( login.getDimension() == user.getDimension() )
|
if ( login.getDimension() == user.getDimension() )
|
||||||
{
|
{
|
||||||
user.unsafe().sendPacket( new Respawn( (Integer) login.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(),
|
user.unsafe().sendPacket( new Respawn( (Integer) login.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(),
|
||||||
(byte) 0, login.getDeathLocation(), login.getPortalCooldown() ) );
|
false, login.getDeathLocation(), login.getPortalCooldown() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
user.setServerEntityId( login.getEntityId() );
|
user.setServerEntityId( login.getEntityId() );
|
||||||
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(),
|
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(),
|
||||||
(byte) 0, login.getDeathLocation(), login.getPortalCooldown() ) );
|
false, login.getDeathLocation(), login.getPortalCooldown() ) );
|
||||||
if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_14 )
|
if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_14 )
|
||||||
{
|
{
|
||||||
user.unsafe().sendPacket( new ViewDistance( login.getViewDistance() ) );
|
user.unsafe().sendPacket( new ViewDistance( login.getViewDistance() ) );
|
||||||
}
|
}
|
||||||
user.setDimension( login.getDimension() );
|
user.setDimension( login.getDimension() );
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cutThrough(ServerConnection server)
|
// Remove from old servers
|
||||||
{
|
|
||||||
if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_20_2 )
|
|
||||||
{
|
|
||||||
if ( user.getServer() != null )
|
|
||||||
{
|
|
||||||
// Begin config mode
|
|
||||||
user.unsafe().sendPacket( new StartConfiguration() );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
ch.setDecodeProtocol( Protocol.CONFIGURATION );
|
|
||||||
ch.write( new LoginAcknowledged() );
|
|
||||||
ch.setEncodeProtocol( Protocol.CONFIGURATION );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove from old servers
|
|
||||||
if ( user.getServer() != null )
|
|
||||||
{
|
|
||||||
user.getServer().setObsolete( true );
|
|
||||||
user.getServer().disconnect( "Quitting" );
|
user.getServer().disconnect( "Quitting" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,6 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
@NonNull
|
@NonNull
|
||||||
private final ProxyServer bungee;
|
private final ProxyServer bungee;
|
||||||
@Getter
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final ChannelWrapper ch;
|
private final ChannelWrapper ch;
|
||||||
@Getter
|
@Getter
|
||||||
@ -125,9 +124,6 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
private final Scoreboard serverSentScoreboard = new Scoreboard();
|
private final Scoreboard serverSentScoreboard = new Scoreboard();
|
||||||
@Getter
|
@Getter
|
||||||
private final Collection<UUID> sentBossBars = new HashSet<>();
|
private final Collection<UUID> sentBossBars = new HashSet<>();
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String lastCommandTabbed;
|
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
@Getter
|
@Getter
|
||||||
private String displayName;
|
private String displayName;
|
||||||
|
@ -20,13 +20,10 @@ import java.io.DataInput;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.md_5.bungee.ServerConnection;
|
import net.md_5.bungee.ServerConnection;
|
||||||
import net.md_5.bungee.ServerConnection.KeepAliveData;
|
import net.md_5.bungee.ServerConnection.KeepAliveData;
|
||||||
import net.md_5.bungee.ServerConnector;
|
|
||||||
import net.md_5.bungee.UserConnection;
|
import net.md_5.bungee.UserConnection;
|
||||||
import net.md_5.bungee.Util;
|
import net.md_5.bungee.Util;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -34,7 +31,6 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
|||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.connection.Server;
|
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||||
import net.md_5.bungee.api.event.ServerDisconnectEvent;
|
import net.md_5.bungee.api.event.ServerDisconnectEvent;
|
||||||
@ -52,13 +48,11 @@ import net.md_5.bungee.netty.ChannelWrapper;
|
|||||||
import net.md_5.bungee.netty.PacketHandler;
|
import net.md_5.bungee.netty.PacketHandler;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
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.ProtocolConstants;
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||||
import net.md_5.bungee.protocol.packet.BossBar;
|
import net.md_5.bungee.protocol.packet.BossBar;
|
||||||
import net.md_5.bungee.protocol.packet.Commands;
|
import net.md_5.bungee.protocol.packet.Commands;
|
||||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||||
import net.md_5.bungee.protocol.packet.Kick;
|
import net.md_5.bungee.protocol.packet.Kick;
|
||||||
import net.md_5.bungee.protocol.packet.Login;
|
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
|
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
|
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
|
||||||
@ -86,7 +80,6 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
private final ProxyServer bungee;
|
private final ProxyServer bungee;
|
||||||
private final UserConnection con;
|
private final UserConnection con;
|
||||||
private final ServerConnection server;
|
private final ServerConnection server;
|
||||||
private boolean receivedLogin;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exception(Throwable t) throws Exception
|
public void exception(Throwable t) throws Exception
|
||||||
@ -138,7 +131,7 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
public void handle(PacketWrapper packet) throws Exception
|
public void handle(PacketWrapper packet) throws Exception
|
||||||
{
|
{
|
||||||
EntityMap rewrite = con.getEntityRewrite();
|
EntityMap rewrite = con.getEntityRewrite();
|
||||||
if ( rewrite != null && con.getCh().getEncodeProtocol() == Protocol.GAME )
|
if ( rewrite != null )
|
||||||
{
|
{
|
||||||
rewrite.rewriteClientbound( packet.buf, con.getServerEntityId(), con.getClientEntityId(), con.getPendingConnection().getVersion() );
|
rewrite.rewriteClientbound( packet.buf, con.getServerEntityId(), con.getClientEntityId(), con.getPendingConnection().getVersion() );
|
||||||
}
|
}
|
||||||
@ -408,27 +401,6 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "GetPlayerServer":
|
|
||||||
{
|
|
||||||
String name = in.readUTF();
|
|
||||||
ProxiedPlayer player = bungee.getPlayer( name );
|
|
||||||
out.writeUTF( "GetPlayerServer" );
|
|
||||||
out.writeUTF( name );
|
|
||||||
if ( player == null )
|
|
||||||
{
|
|
||||||
out.writeUTF( "" );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Server srv = player.getServer();
|
|
||||||
if ( srv == null )
|
|
||||||
{
|
|
||||||
out.writeUTF( "" );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
out.writeUTF( srv.getInfo().getName() );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "IP":
|
case "IP":
|
||||||
out.writeUTF( "IP" );
|
out.writeUTF( "IP" );
|
||||||
if ( con.getSocketAddress() instanceof InetSocketAddress )
|
if ( con.getSocketAddress() instanceof InetSocketAddress )
|
||||||
@ -590,16 +562,6 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "KickPlayerRaw":
|
|
||||||
{
|
|
||||||
ProxiedPlayer player = bungee.getPlayer( in.readUTF() );
|
|
||||||
if ( player != null )
|
|
||||||
{
|
|
||||||
BaseComponent[] kickReason = ComponentSerializer.parse( in.readUTF() );
|
|
||||||
player.disconnect( kickReason );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check we haven't set out to null, and we have written data, if so reply back back along the BungeeCord channel
|
// Check we haven't set out to null, and we have written data, if so reply back back along the BungeeCord channel
|
||||||
@ -652,23 +614,6 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
return input.getText();
|
return input.getText();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
} else
|
|
||||||
{
|
|
||||||
String last = con.getLastCommandTabbed();
|
|
||||||
if ( last != null )
|
|
||||||
{
|
|
||||||
String commandName = last.toLowerCase( Locale.ROOT );
|
|
||||||
commands.addAll( bungee.getPluginManager().getCommands().stream()
|
|
||||||
.filter( (entry) ->
|
|
||||||
{
|
|
||||||
String lowerCase = entry.getKey().toLowerCase( Locale.ROOT );
|
|
||||||
return lowerCase.startsWith( commandName ) && entry.getValue().hasPermission( con ) && !bungee.getDisabledCommands().contains( lowerCase );
|
|
||||||
} )
|
|
||||||
.map( (stringCommandEntry) -> '/' + stringCommandEntry.getKey() )
|
|
||||||
.collect( Collectors.toList() ) );
|
|
||||||
commands.sort( null );
|
|
||||||
con.setLastCommandTabbed( null );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TabCompleteResponseEvent tabCompleteResponseEvent = new TabCompleteResponseEvent( server, con, new ArrayList<>( commands ) );
|
TabCompleteResponseEvent tabCompleteResponseEvent = new TabCompleteResponseEvent( server, con, new ArrayList<>( commands ) );
|
||||||
@ -760,17 +705,6 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
throw CancelSendSignal.INSTANCE;
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(Login login) throws Exception
|
|
||||||
{
|
|
||||||
Preconditions.checkState( !receivedLogin, "Not expecting login" );
|
|
||||||
|
|
||||||
receivedLogin = true;
|
|
||||||
ServerConnector.handleLogin( bungee, server.getCh(), con, server.getInfo(), null, server, login );
|
|
||||||
|
|
||||||
throw CancelSendSignal.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,6 @@ import net.md_5.bungee.protocol.packet.Handshake;
|
|||||||
import net.md_5.bungee.protocol.packet.Kick;
|
import net.md_5.bungee.protocol.packet.Kick;
|
||||||
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
||||||
import net.md_5.bungee.protocol.packet.LegacyPing;
|
import net.md_5.bungee.protocol.packet.LegacyPing;
|
||||||
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
|
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||||
import net.md_5.bungee.protocol.packet.LoginSuccess;
|
import net.md_5.bungee.protocol.packet.LoginSuccess;
|
||||||
@ -112,7 +111,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
private boolean legacy;
|
private boolean legacy;
|
||||||
@Getter
|
@Getter
|
||||||
private String extraDataInHandshake = "";
|
private String extraDataInHandshake = "";
|
||||||
private UserConnection userCon;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldHandle(PacketWrapper packet) throws Exception
|
public boolean shouldHandle(PacketWrapper packet) throws Exception
|
||||||
@ -123,12 +121,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
private enum State
|
private enum State
|
||||||
{
|
{
|
||||||
|
|
||||||
HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING, CONFIGURING;
|
HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canSendKickMessage()
|
private boolean canSendKickMessage()
|
||||||
{
|
{
|
||||||
return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING || thisState == State.CONFIGURING;
|
return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -595,18 +593,29 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
{
|
{
|
||||||
if ( !ch.isClosing() )
|
if ( !ch.isClosing() )
|
||||||
{
|
{
|
||||||
userCon = new UserConnection( bungee, ch, getName(), InitialHandler.this );
|
UserConnection userCon = new UserConnection( bungee, ch, getName(), InitialHandler.this );
|
||||||
userCon.setCompressionThreshold( BungeeCord.getInstance().config.getCompressionThreshold() );
|
userCon.setCompressionThreshold( BungeeCord.getInstance().config.getCompressionThreshold() );
|
||||||
|
userCon.init();
|
||||||
|
|
||||||
unsafe.sendPacket( new LoginSuccess( getUniqueId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
|
unsafe.sendPacket( new LoginSuccess( getUniqueId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
|
||||||
if ( getVersion() >= ProtocolConstants.MINECRAFT_1_20_2 )
|
ch.setProtocol( Protocol.GAME );
|
||||||
|
|
||||||
|
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
||||||
|
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
|
||||||
|
ServerInfo server;
|
||||||
|
if ( bungee.getReconnectHandler() != null )
|
||||||
{
|
{
|
||||||
thisState = State.CONFIGURING;
|
server = bungee.getReconnectHandler().getServer( userCon );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
ch.setProtocol( Protocol.GAME );
|
server = AbstractReconnectHandler.getForcedHost( InitialHandler.this );
|
||||||
finish2();
|
|
||||||
}
|
}
|
||||||
|
if ( server == null )
|
||||||
|
{
|
||||||
|
server = bungee.getServerInfo( listener.getDefaultServer() );
|
||||||
|
}
|
||||||
|
|
||||||
|
userCon.connect( server, null, true, ServerConnectEvent.Reason.JOIN_PROXY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
@ -617,37 +626,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
bungee.getPluginManager().callEvent( new LoginEvent( InitialHandler.this, complete ) );
|
bungee.getPluginManager().callEvent( new LoginEvent( InitialHandler.this, complete ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(LoginAcknowledged loginAcknowledged) throws Exception
|
|
||||||
{
|
|
||||||
Preconditions.checkState( thisState == State.CONFIGURING, "Not expecting CONFIGURING" );
|
|
||||||
|
|
||||||
finish2();
|
|
||||||
ch.setEncodeProtocol( Protocol.CONFIGURATION );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void finish2()
|
|
||||||
{
|
|
||||||
userCon.init();
|
|
||||||
|
|
||||||
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
|
||||||
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
|
|
||||||
ServerInfo server;
|
|
||||||
if ( bungee.getReconnectHandler() != null )
|
|
||||||
{
|
|
||||||
server = bungee.getReconnectHandler().getServer( userCon );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
server = AbstractReconnectHandler.getForcedHost( InitialHandler.this );
|
|
||||||
}
|
|
||||||
if ( server == null )
|
|
||||||
{
|
|
||||||
server = bungee.getServerInfo( listener.getDefaultServer() );
|
|
||||||
}
|
|
||||||
|
|
||||||
userCon.connect( server, null, true, ServerConnectEvent.Reason.JOIN_PROXY );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(LoginPayloadResponse response) throws Exception
|
public void handle(LoginPayloadResponse response) throws Exception
|
||||||
{
|
{
|
||||||
|
@ -25,18 +25,15 @@ import net.md_5.bungee.forge.ForgeConstants;
|
|||||||
import net.md_5.bungee.netty.ChannelWrapper;
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
import net.md_5.bungee.netty.PacketHandler;
|
import net.md_5.bungee.netty.PacketHandler;
|
||||||
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.ProtocolConstants;
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||||
import net.md_5.bungee.protocol.packet.Chat;
|
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.KeepAlive;
|
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||||
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
|
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
|
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
|
||||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
|
||||||
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||||
import net.md_5.bungee.util.AllowedCharacters;
|
import net.md_5.bungee.util.AllowedCharacters;
|
||||||
@ -54,6 +51,7 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
|
|
||||||
BungeeCord.getInstance().addConnection( con );
|
BungeeCord.getInstance().addConnection( con );
|
||||||
con.getTabListHandler().onConnect();
|
con.getTabListHandler().onConnect();
|
||||||
|
con.unsafe().sendPacket( BungeeCord.getInstance().registerChannels( con.getPendingConnection().getVersion() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -136,7 +134,7 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
if ( con.getServer() != null )
|
if ( con.getServer() != null )
|
||||||
{
|
{
|
||||||
EntityMap rewrite = con.getEntityRewrite();
|
EntityMap rewrite = con.getEntityRewrite();
|
||||||
if ( rewrite != null && con.getServer().getCh().getEncodeProtocol() == Protocol.GAME )
|
if ( rewrite != null )
|
||||||
{
|
{
|
||||||
rewrite.rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId(), con.getPendingConnection().getVersion() );
|
rewrite.rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId(), con.getPendingConnection().getVersion() );
|
||||||
}
|
}
|
||||||
@ -215,9 +213,8 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
{
|
{
|
||||||
List<String> suggestions = new ArrayList<>();
|
List<String> suggestions = new ArrayList<>();
|
||||||
boolean isRegisteredCommand = false;
|
boolean isRegisteredCommand = false;
|
||||||
boolean isCommand = tabComplete.getCursor().startsWith( "/" );
|
|
||||||
|
|
||||||
if ( isCommand )
|
if ( tabComplete.getCursor().startsWith( "/" ) )
|
||||||
{
|
{
|
||||||
isRegisteredCommand = bungee.getPluginManager().dispatchCommand( con, tabComplete.getCursor().substring( 1 ), suggestions );
|
isRegisteredCommand = bungee.getPluginManager().dispatchCommand( con, tabComplete.getCursor().substring( 1 ), suggestions );
|
||||||
}
|
}
|
||||||
@ -260,15 +257,6 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
{
|
{
|
||||||
throw CancelSendSignal.INSTANCE;
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isCommand && con.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_13 )
|
|
||||||
{
|
|
||||||
int lastSpace = tabComplete.getCursor().lastIndexOf( ' ' );
|
|
||||||
if ( lastSpace == -1 )
|
|
||||||
{
|
|
||||||
con.setLastCommandTabbed( tabComplete.getCursor().substring( 1 ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -321,19 +309,6 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
con.getPendingConnection().relayMessage( pluginMessage );
|
con.getPendingConnection().relayMessage( pluginMessage );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(StartConfiguration startConfiguration) throws Exception
|
|
||||||
{
|
|
||||||
ChannelWrapper ch = con.getServer().getCh();
|
|
||||||
if ( ch.getDecodeProtocol() == Protocol.LOGIN )
|
|
||||||
{
|
|
||||||
ch.setDecodeProtocol( Protocol.CONFIGURATION );
|
|
||||||
ch.write( new LoginAcknowledged() );
|
|
||||||
ch.setEncodeProtocol( Protocol.CONFIGURATION );
|
|
||||||
throw CancelSendSignal.INSTANCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@ -82,8 +82,6 @@ public abstract class EntityMap
|
|||||||
case ProtocolConstants.MINECRAFT_1_19_4:
|
case ProtocolConstants.MINECRAFT_1_19_4:
|
||||||
case ProtocolConstants.MINECRAFT_1_20:
|
case ProtocolConstants.MINECRAFT_1_20:
|
||||||
return EntityMap_1_16_2.INSTANCE_1_19_4;
|
return EntityMap_1_16_2.INSTANCE_1_19_4;
|
||||||
case ProtocolConstants.MINECRAFT_1_20_2:
|
|
||||||
return EntityMap_1_16_2.INSTANCE_1_20_2;
|
|
||||||
}
|
}
|
||||||
throw new RuntimeException( "Version " + version + " has no entity map" );
|
throw new RuntimeException( "Version " + version + " has no entity map" );
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ class EntityMap_1_16_2 extends EntityMap
|
|||||||
static final EntityMap_1_16_2 INSTANCE_1_19 = new EntityMap_1_16_2( 0x02, 0x2F );
|
static final EntityMap_1_16_2 INSTANCE_1_19 = new EntityMap_1_16_2( 0x02, 0x2F );
|
||||||
static final EntityMap_1_16_2 INSTANCE_1_19_1 = new EntityMap_1_16_2( 0x02, 0x30 );
|
static final EntityMap_1_16_2 INSTANCE_1_19_1 = new EntityMap_1_16_2( 0x02, 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_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 );
|
|
||||||
//
|
//
|
||||||
private final int spawnPlayerId;
|
private final int spawnPlayerId;
|
||||||
private final int spectateId;
|
private final int spectateId;
|
||||||
|
@ -11,7 +11,6 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.md_5.bungee.compress.PacketCompressor;
|
import net.md_5.bungee.compress.PacketCompressor;
|
||||||
import net.md_5.bungee.compress.PacketDecompressor;
|
import net.md_5.bungee.compress.PacketDecompressor;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.MinecraftDecoder;
|
import net.md_5.bungee.protocol.MinecraftDecoder;
|
||||||
import net.md_5.bungee.protocol.MinecraftEncoder;
|
import net.md_5.bungee.protocol.MinecraftEncoder;
|
||||||
import net.md_5.bungee.protocol.PacketWrapper;
|
import net.md_5.bungee.protocol.PacketWrapper;
|
||||||
@ -36,31 +35,10 @@ public class ChannelWrapper
|
|||||||
this.remoteAddress = ( this.ch.remoteAddress() == null ) ? this.ch.parent().localAddress() : this.ch.remoteAddress();
|
this.remoteAddress = ( this.ch.remoteAddress() == null ) ? this.ch.parent().localAddress() : this.ch.remoteAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Protocol getDecodeProtocol()
|
|
||||||
{
|
|
||||||
return ch.pipeline().get( MinecraftDecoder.class ).getProtocol();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDecodeProtocol(Protocol protocol)
|
|
||||||
{
|
|
||||||
ch.pipeline().get( MinecraftDecoder.class ).setProtocol( protocol );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Protocol getEncodeProtocol()
|
|
||||||
{
|
|
||||||
return ch.pipeline().get( MinecraftEncoder.class ).getProtocol();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEncodeProtocol(Protocol protocol)
|
|
||||||
{
|
|
||||||
ch.pipeline().get( MinecraftEncoder.class ).setProtocol( protocol );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProtocol(Protocol protocol)
|
public void setProtocol(Protocol protocol)
|
||||||
{
|
{
|
||||||
setDecodeProtocol( protocol );
|
ch.pipeline().get( MinecraftDecoder.class ).setProtocol( protocol );
|
||||||
setEncodeProtocol( protocol );
|
ch.pipeline().get( MinecraftEncoder.class ).setProtocol( protocol );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVersion(int protocol)
|
public void setVersion(int protocol)
|
||||||
@ -73,29 +51,13 @@ public class ChannelWrapper
|
|||||||
{
|
{
|
||||||
if ( !closed )
|
if ( !closed )
|
||||||
{
|
{
|
||||||
DefinedPacket defined = null;
|
|
||||||
if ( packet instanceof PacketWrapper )
|
if ( packet instanceof PacketWrapper )
|
||||||
{
|
{
|
||||||
PacketWrapper wrapper = (PacketWrapper) packet;
|
( (PacketWrapper) packet ).setReleased( true );
|
||||||
wrapper.setReleased( true );
|
ch.writeAndFlush( ( (PacketWrapper) packet ).buf, ch.voidPromise() );
|
||||||
ch.writeAndFlush( wrapper.buf, ch.voidPromise() );
|
|
||||||
defined = wrapper.packet;
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
ch.writeAndFlush( packet, ch.voidPromise() );
|
ch.writeAndFlush( packet, ch.voidPromise() );
|
||||||
if ( packet instanceof DefinedPacket )
|
|
||||||
{
|
|
||||||
defined = (DefinedPacket) packet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( defined != null )
|
|
||||||
{
|
|
||||||
Protocol nextProtocol = defined.nextProtocol();
|
|
||||||
if ( nextProtocol != null )
|
|
||||||
{
|
|
||||||
setEncodeProtocol( nextProtocol );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,11 +124,11 @@ public class ChannelWrapper
|
|||||||
|
|
||||||
public void setCompressionThreshold(int compressionThreshold)
|
public void setCompressionThreshold(int compressionThreshold)
|
||||||
{
|
{
|
||||||
if ( ch.pipeline().get( PacketCompressor.class ) == null && compressionThreshold >= 0 )
|
if ( ch.pipeline().get( PacketCompressor.class ) == null && compressionThreshold != -1 )
|
||||||
{
|
{
|
||||||
addBefore( PipelineUtils.PACKET_ENCODER, "compress", new PacketCompressor() );
|
addBefore( PipelineUtils.PACKET_ENCODER, "compress", new PacketCompressor() );
|
||||||
}
|
}
|
||||||
if ( compressionThreshold >= 0 )
|
if ( compressionThreshold != -1 )
|
||||||
{
|
{
|
||||||
ch.pipeline().get( PacketCompressor.class ).setThreshold( compressionThreshold );
|
ch.pipeline().get( PacketCompressor.class ).setThreshold( compressionThreshold );
|
||||||
} else
|
} else
|
||||||
@ -174,11 +136,11 @@ public class ChannelWrapper
|
|||||||
ch.pipeline().remove( "compress" );
|
ch.pipeline().remove( "compress" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ch.pipeline().get( PacketDecompressor.class ) == null && compressionThreshold >= 0 )
|
if ( ch.pipeline().get( PacketDecompressor.class ) == null && compressionThreshold != -1 )
|
||||||
{
|
{
|
||||||
addBefore( PipelineUtils.PACKET_DECODER, "decompress", new PacketDecompressor() );
|
addBefore( PipelineUtils.PACKET_DECODER, "decompress", new PacketDecompressor() );
|
||||||
}
|
}
|
||||||
if ( compressionThreshold < 0 )
|
if ( compressionThreshold == -1 )
|
||||||
{
|
{
|
||||||
ch.pipeline().remove( "decompress" );
|
ch.pipeline().remove( "decompress" );
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ import net.md_5.bungee.connection.PingHandler;
|
|||||||
import net.md_5.bungee.protocol.BadPacketException;
|
import net.md_5.bungee.protocol.BadPacketException;
|
||||||
import net.md_5.bungee.protocol.OverflowPacketException;
|
import net.md_5.bungee.protocol.OverflowPacketException;
|
||||||
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.util.QuietException;
|
import net.md_5.bungee.util.QuietException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,18 +101,9 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketWrapper packet = (PacketWrapper) msg;
|
|
||||||
if ( packet.packet != null )
|
|
||||||
{
|
|
||||||
Protocol nextProtocol = packet.packet.nextProtocol();
|
|
||||||
if ( nextProtocol != null )
|
|
||||||
{
|
|
||||||
channel.setDecodeProtocol( nextProtocol );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( handler != null )
|
if ( handler != null )
|
||||||
{
|
{
|
||||||
|
PacketWrapper packet = (PacketWrapper) msg;
|
||||||
boolean sendPacket = handler.shouldHandle( packet );
|
boolean sendPacket = handler.shouldHandle( packet );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-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.2-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-SLF4J</name>
|
<name>BungeeCord-SLF4J</name>
|
||||||
|
Loading…
Reference in New Issue
Block a user