mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-03 12:27:08 -05:00
Update dependencies (#763)
* Update dependencies * Use static imports for Assertions * Change commit hash from jitpack
This commit is contained in:
parent
6f53d57f8d
commit
64d58248d6
30 changed files with 124 additions and 125 deletions
|
@ -55,4 +55,4 @@ Please join [the GeyserMC Discord server](https://discord.gg/geysermc) and visit
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MCProtocolLib is licensed under the **[MIT license](http://www.opensource.org/licenses/mit-license.html)**.
|
MCProtocolLib is licensed under the **[MIT license](https://opensource.org/license/mit/)**.
|
||||||
|
|
83
pom.xml
83
pom.xml
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<name>MCProtocolLib</name>
|
<name>MCProtocolLib</name>
|
||||||
<description>MCProtocolLib is a simple library for communicating with Minecraft clients and servers.</description>
|
<description>MCProtocolLib is a simple library for communicating with Minecraft clients and servers.</description>
|
||||||
<url>http://github.com/GeyserMC/MCProtocolLib/</url>
|
<url>https://github.com/GeyserMC/MCProtocolLib/</url>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@github.com:GeyserMC/MCProtocolLib.git</connection>
|
<connection>scm:git:git@github.com:GeyserMC/MCProtocolLib.git</connection>
|
||||||
|
@ -20,15 +20,15 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<jdk.version>1.8</jdk.version>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<adventure.version>4.9.3</adventure.version>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<argLine></argLine>
|
<adventure.version>4.14.0</adventure.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>MIT</name>
|
<name>MIT</name>
|
||||||
<url>http://www.opensource.org/licenses/mit-license.html</url>
|
<url>https://opensource.org/license/mit/</url>
|
||||||
<distribution>repo</distribution>
|
<distribution>repo</distribution>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
|
@ -81,6 +81,7 @@
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- Minecraft related libraries -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.steveice10</groupId>
|
<groupId>com.github.steveice10</groupId>
|
||||||
<artifactId>opennbt</artifactId>
|
<artifactId>opennbt</artifactId>
|
||||||
|
@ -90,9 +91,10 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.GeyserMC</groupId>
|
<groupId>com.github.GeyserMC</groupId>
|
||||||
<artifactId>mcauthlib</artifactId>
|
<artifactId>mcauthlib</artifactId>
|
||||||
<version>6f3d6aada5</version>
|
<version>6621fd081c</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Kyori adventure -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||||
|
@ -105,12 +107,20 @@
|
||||||
<version>${adventure.version}</version>
|
<version>${adventure.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Lombok and annotations -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.22</version>
|
<version>1.18.30</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.spotbugs</groupId>
|
||||||
|
<artifactId>spotbugs-annotations</artifactId>
|
||||||
|
<version>4.7.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Math utilities -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.cloudburstmc.math</groupId>
|
<groupId>org.cloudburstmc.math</groupId>
|
||||||
<artifactId>api</artifactId>
|
<artifactId>api</artifactId>
|
||||||
|
@ -123,48 +133,45 @@
|
||||||
<version>2.0</version>
|
<version>2.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Stripped down fastutil -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.nukkitx.fastutil</groupId>
|
<groupId>com.nukkitx.fastutil</groupId>
|
||||||
<artifactId>fastutil-object-int-maps</artifactId>
|
<artifactId>fastutil-object-int-maps</artifactId>
|
||||||
<version>8.5.2</version>
|
<version>8.5.3</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>com.nukkitx.fastutil</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>fastutil-int-object-maps</artifactId>
|
||||||
<version>4.13.1</version>
|
<version>8.5.3</version>
|
||||||
<scope>test</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Netty -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-all</artifactId>
|
<artifactId>netty-all</artifactId>
|
||||||
<version>4.1.66.Final</version>
|
<version>4.1.99.Final</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-codec-haproxy</artifactId>
|
<artifactId>netty-codec-haproxy</artifactId>
|
||||||
<version>4.1.66.Final</version>
|
<version>4.1.99.Final</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty.incubator</groupId>
|
<groupId>io.netty.incubator</groupId>
|
||||||
<artifactId>netty-incubator-transport-native-io_uring</artifactId>
|
<artifactId>netty-incubator-transport-native-io_uring</artifactId>
|
||||||
<version>0.0.8.Final</version>
|
<version>0.0.23.Final</version>
|
||||||
<classifier>linux-x86_64</classifier>
|
<classifier>linux-x86_64</classifier>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Test dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.spotbugs</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>spotbugs-annotations</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
<version>4.3.0</version>
|
<version>5.8.2</version>
|
||||||
<scope>provided</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.nukkitx.fastutil</groupId>
|
|
||||||
<artifactId>fastutil-int-object-maps</artifactId>
|
|
||||||
<version>8.5.2</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -174,40 +181,32 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.3.1</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<version>3.0.2</version>
|
<version>3.3.1</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>3.0.2</version>
|
<version>3.3.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.7.0</version>
|
<version>3.11.0</version>
|
||||||
<configuration>
|
|
||||||
<source>${jdk.version}</source>
|
|
||||||
<target>${jdk.version}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.22.0</version>
|
<version>3.1.2</version>
|
||||||
<configuration>
|
|
||||||
<!-- Force the right file encoding during unit testing -->
|
|
||||||
<argLine>-Dfile.encoding=${project.build.sourceEncoding} @{argLine}</argLine>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.6.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>attach-javadocs</id>
|
<id>attach-javadocs</id>
|
||||||
|
@ -225,7 +224,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.3.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>attach-sources</id>
|
<id>attach-sources</id>
|
||||||
|
@ -238,12 +237,12 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-install-plugin</artifactId>
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
<version>2.5.2</version>
|
<version>3.1.1</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
<version>2.8.2</version>
|
<version>3.1.1</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.github.steveice10.mc.protocol.data;
|
package com.github.steveice10.mc.protocol.data;
|
||||||
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.gson.legacyimpl.NBTLegacyHoverEventSerializer;
|
import net.kyori.adventure.text.serializer.json.legacyimpl.NBTLegacyHoverEventSerializer;
|
||||||
|
|
||||||
public final class DefaultComponentSerializer {
|
public final class DefaultComponentSerializer {
|
||||||
private static GsonComponentSerializer serializer = GsonComponentSerializer.builder()
|
private static GsonComponentSerializer serializer = GsonComponentSerializer.builder()
|
||||||
|
|
|
@ -7,5 +7,5 @@ import lombok.NonNull;
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class BreakBlockEventData implements LevelEventData {
|
public class BreakBlockEventData implements LevelEventData {
|
||||||
private final @NonNull int blockState;
|
private final int blockState;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,6 @@ public interface Server {
|
||||||
* @return Value of the flag.
|
* @return Value of the flag.
|
||||||
* @throws IllegalStateException If the flag's value isn't of the required type.
|
* @throws IllegalStateException If the flag's value isn't of the required type.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
<T> T getGlobalFlag(String key, T def);
|
<T> T getGlobalFlag(String key, T def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,6 +115,8 @@ public interface Server {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds the listener to its host and port.
|
* Binds the listener to its host and port.
|
||||||
|
*
|
||||||
|
* @return The server.
|
||||||
*/
|
*/
|
||||||
AbstractServer bind();
|
AbstractServer bind();
|
||||||
|
|
||||||
|
@ -123,6 +124,7 @@ public interface Server {
|
||||||
* Binds the listener to its host and port.
|
* Binds the listener to its host and port.
|
||||||
*
|
*
|
||||||
* @param wait Whether to wait for the listener to finish binding.
|
* @param wait Whether to wait for the listener to finish binding.
|
||||||
|
* @return The server.
|
||||||
*/
|
*/
|
||||||
AbstractServer bind(boolean wait);
|
AbstractServer bind(boolean wait);
|
||||||
|
|
||||||
|
@ -131,6 +133,7 @@ public interface Server {
|
||||||
*
|
*
|
||||||
* @param wait Whether to wait for the listener to finish binding.
|
* @param wait Whether to wait for the listener to finish binding.
|
||||||
* @param callback Callback to call when the listener has finished binding.
|
* @param callback Callback to call when the listener has finished binding.
|
||||||
|
* @return The server.
|
||||||
*/
|
*/
|
||||||
AbstractServer bind(boolean wait, Runnable callback);
|
AbstractServer bind(boolean wait, Runnable callback);
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,9 @@ import com.github.steveice10.packetlib.packet.Packet;
|
||||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||||
import com.github.steveice10.packetlib.tcp.TcpServer;
|
import com.github.steveice10.packetlib.tcp.TcpServer;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
@ -30,9 +30,7 @@ import static com.github.steveice10.mc.protocol.MinecraftConstants.SERVER_INFO_H
|
||||||
import static com.github.steveice10.mc.protocol.MinecraftConstants.SERVER_LOGIN_HANDLER_KEY;
|
import static com.github.steveice10.mc.protocol.MinecraftConstants.SERVER_LOGIN_HANDLER_KEY;
|
||||||
import static com.github.steveice10.mc.protocol.MinecraftConstants.VERIFY_USERS_KEY;
|
import static com.github.steveice10.mc.protocol.MinecraftConstants.VERIFY_USERS_KEY;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class MinecraftProtocolTest {
|
public class MinecraftProtocolTest {
|
||||||
private static final String HOST = "localhost";
|
private static final String HOST = "localhost";
|
||||||
|
@ -49,7 +47,7 @@ public class MinecraftProtocolTest {
|
||||||
|
|
||||||
private static Server server;
|
private static Server server;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void setupServer() {
|
public static void setupServer() {
|
||||||
server = new TcpServer(HOST, PORT, MinecraftProtocol::new);
|
server = new TcpServer(HOST, PORT, MinecraftProtocol::new);
|
||||||
server.setGlobalFlag(VERIFY_USERS_KEY, false);
|
server.setGlobalFlag(VERIFY_USERS_KEY, false);
|
||||||
|
@ -66,10 +64,10 @@ public class MinecraftProtocolTest {
|
||||||
session.send(JOIN_GAME_PACKET);
|
session.send(JOIN_GAME_PACKET);
|
||||||
});
|
});
|
||||||
|
|
||||||
assertTrue("Could not bind server.", server.bind(true).isListening());
|
assertTrue(server.bind(true).isListening(), "Could not bind server.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void tearDownServer() {
|
public static void tearDownServer() {
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
server.close(true);
|
server.close(true);
|
||||||
|
@ -87,8 +85,8 @@ public class MinecraftProtocolTest {
|
||||||
session.connect();
|
session.connect();
|
||||||
|
|
||||||
handler.status.await(4, SECONDS);
|
handler.status.await(4, SECONDS);
|
||||||
assertNotNull("Failed to get server info.", handler.info);
|
assertNotNull(handler.info, "Failed to get server info.");
|
||||||
assertEquals("Received incorrect server info.", SERVER_INFO, handler.info);
|
assertEquals(SERVER_INFO, handler.info, "Received incorrect server info.");
|
||||||
} finally {
|
} finally {
|
||||||
session.disconnect("Status test complete.");
|
session.disconnect("Status test complete.");
|
||||||
}
|
}
|
||||||
|
@ -104,8 +102,8 @@ public class MinecraftProtocolTest {
|
||||||
session.connect();
|
session.connect();
|
||||||
|
|
||||||
listener.login.await(4, SECONDS);
|
listener.login.await(4, SECONDS);
|
||||||
assertNotNull("Failed to log in.", listener.packet);
|
assertNotNull(listener.packet, "Failed to log in.");
|
||||||
assertEquals("Received incorrect join packet.", JOIN_GAME_PACKET, listener.packet);
|
assertEquals(JOIN_GAME_PACKET, listener.packet, "Received incorrect join packet.");
|
||||||
} finally {
|
} finally {
|
||||||
session.disconnect("Login test complete.");
|
session.disconnect("Login test complete.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,21 @@ import com.github.steveice10.mc.protocol.data.game.chunk.palette.SingletonPalett
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
|
||||||
public class ChunkTest {
|
public class ChunkTest {
|
||||||
private final List<ChunkSection> chunkSectionsToTest = new ArrayList<>();
|
private final List<ChunkSection> chunkSectionsToTest = new ArrayList<>();
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
chunkSectionsToTest.add(new ChunkSection());
|
chunkSectionsToTest.add(new ChunkSection());
|
||||||
|
|
||||||
|
@ -49,7 +51,8 @@ public class ChunkTest {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
Assert.assertEquals("Decoded packet does not match original: " + section + " vs " + decoded, section, decoded);
|
|
||||||
|
assertEquals(section, decoded, "Decoded packet does not match original: " + section + " vs " + decoded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,10 +60,10 @@ public class ChunkTest {
|
||||||
public void testDeepCopy() {
|
public void testDeepCopy() {
|
||||||
for (ChunkSection section : chunkSectionsToTest) {
|
for (ChunkSection section : chunkSectionsToTest) {
|
||||||
ChunkSection copy = new ChunkSection(section);
|
ChunkSection copy = new ChunkSection(section);
|
||||||
Assert.assertEquals("Deep copy does not match original: " + section + " vs " + copy, section, copy);
|
assertEquals(section, copy, "Deep copy does not match original: " + section + " vs " + copy);
|
||||||
|
|
||||||
copy.setBlock(1, 1, 1, 10);
|
copy.setBlock(1, 1, 1, 10);
|
||||||
Assert.assertNotEquals("Deep copy is not deep: " + section + " vs " + copy, section, copy);
|
assertNotEquals(section, copy, "Deep copy is not deep: " + section + " vs " + copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,12 @@ import com.github.steveice10.mc.protocol.data.game.entity.Effect;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Miscellaneous tests for reading and writing classes to/from the network
|
* Miscellaneous tests for reading and writing classes to/from the network
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +23,7 @@ public class NetworkDataTests {
|
||||||
ByteBuf buf = Unpooled.buffer();
|
ByteBuf buf = Unpooled.buffer();
|
||||||
helper.writeEffect(buf, effect);
|
helper.writeEffect(buf, effect);
|
||||||
|
|
||||||
Assert.assertEquals(effect, helper.readEffect(buf));
|
assertEquals(effect, helper.readEffect(buf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,12 @@ import com.github.steveice10.packetlib.packet.Packet;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public abstract class PacketTest {
|
public abstract class PacketTest {
|
||||||
private MinecraftPacket[] packets;
|
private MinecraftPacket[] packets;
|
||||||
|
@ -29,7 +29,7 @@ public abstract class PacketTest {
|
||||||
|
|
||||||
Packet decoded = this.createPacket(packet.getClass(), helper, buf);
|
Packet decoded = this.createPacket(packet.getClass(), helper, buf);
|
||||||
|
|
||||||
assertEquals("Decoded packet does not match original: " + packet + " vs " + decoded, packet, decoded);
|
assertEquals(packet, decoded, "Decoded packet does not match original: " + packet + " vs " + decoded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@ import com.github.steveice10.mc.protocol.codec.MinecraftCodec;
|
||||||
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
|
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
|
||||||
import com.github.steveice10.mc.protocol.data.handshake.HandshakeIntent;
|
import com.github.steveice10.mc.protocol.data.handshake.HandshakeIntent;
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ClientIntentionPacketTest extends PacketTest {
|
public class ClientIntentionPacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
List<MinecraftPacket> packets = new ArrayList<>();
|
List<MinecraftPacket> packets = new ArrayList<>();
|
||||||
for (HandshakeIntent intent : HandshakeIntent.values()) {
|
for (HandshakeIntent intent : HandshakeIntent.values()) {
|
||||||
|
|
|
@ -7,12 +7,12 @@ import com.github.steveice10.mc.protocol.data.game.command.SuggestionType;
|
||||||
import com.github.steveice10.mc.protocol.data.game.command.properties.DoubleProperties;
|
import com.github.steveice10.mc.protocol.data.game.command.properties.DoubleProperties;
|
||||||
import com.github.steveice10.mc.protocol.data.game.command.properties.StringProperties;
|
import com.github.steveice10.mc.protocol.data.game.command.properties.StringProperties;
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
public class ClientboundCommandsPacketTest extends PacketTest {
|
public class ClientboundCommandsPacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(new ClientboundCommandsPacket(
|
this.setPackets(new ClientboundCommandsPacket(
|
||||||
new CommandNode[]{
|
new CommandNode[]{
|
||||||
|
|
|
@ -5,16 +5,12 @@ import com.github.steveice10.mc.protocol.data.game.recipe.CraftingBookCategory;
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
|
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.Recipe;
|
import com.github.steveice10.mc.protocol.data.game.recipe.Recipe;
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType;
|
import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType;
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.CookedRecipeData;
|
import com.github.steveice10.mc.protocol.data.game.recipe.data.*;
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData;
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData;
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.SmithingTransformRecipeData;
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.StoneCuttingRecipeData;
|
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
public class ServerDeclareRecipesTest extends PacketTest {
|
public class ServerDeclareRecipesTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(
|
this.setPackets(
|
||||||
new ClientboundUpdateRecipesPacket(
|
new ClientboundUpdateRecipesPacket(
|
||||||
|
|
|
@ -3,10 +3,10 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level;
|
||||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockChangeEntry;
|
import com.github.steveice10.mc.protocol.data.game.level.block.BlockChangeEntry;
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.cloudburstmc.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
public class ClientboundBlockUpdatePacketTest extends PacketTest {
|
public class ClientboundBlockUpdatePacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(
|
this.setPackets(
|
||||||
new ClientboundBlockUpdatePacket(new BlockChangeEntry(
|
new ClientboundBlockUpdatePacket(new BlockChangeEntry(
|
||||||
|
|
|
@ -5,14 +5,14 @@ import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityInfo;
|
||||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityType;
|
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityType;
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class ClientboundLevelChunkWithLightPacketTest extends PacketTest {
|
public class ClientboundLevelChunkWithLightPacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
this.setPackets(
|
this.setPackets(
|
||||||
new ClientboundLevelChunkWithLightPacket(0, 0,
|
new ClientboundLevelChunkWithLightPacket(0, 0,
|
||||||
|
|
|
@ -3,11 +3,11 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level;
|
||||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockChangeEntry;
|
import com.github.steveice10.mc.protocol.data.game.level.block.BlockChangeEntry;
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.cloudburstmc.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
public class ClientboundSectionBlocksUpdatePacketTest extends PacketTest {
|
public class ClientboundSectionBlocksUpdatePacketTest extends PacketTest {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(
|
this.setPackets(
|
||||||
new ClientboundSectionBlocksUpdatePacket(3, 4, 12, new BlockChangeEntry(Vector3i.from(50, 65, 200), 3))
|
new ClientboundSectionBlocksUpdatePacket(3, 4, 12, new BlockChangeEntry(Vector3i.from(50, 65, 200), 3))
|
||||||
|
|
|
@ -12,13 +12,13 @@ import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEntityDataPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEntityDataPacket;
|
||||||
import org.cloudburstmc.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
public class ClientboundSetEntityDataPacketTest extends PacketTest {
|
public class ClientboundSetEntityDataPacketTest extends PacketTest {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(
|
this.setPackets(
|
||||||
new ClientboundSetEntityDataPacket(0, new EntityMetadata[0]),
|
new ClientboundSetEntityDataPacket(0, new EntityMetadata[0]),
|
||||||
|
|
|
@ -5,11 +5,11 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Equipment;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEquipmentPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEquipmentPacket;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
public class ClientboundSetEquipmentPacketTest extends PacketTest {
|
public class ClientboundSetEquipmentPacketTest extends PacketTest {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(
|
this.setPackets(
|
||||||
new ClientboundSetEquipmentPacket(1, new Equipment[]{
|
new ClientboundSetEquipmentPacket(1, new Equipment[]{
|
||||||
|
|
|
@ -6,11 +6,11 @@ import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor;
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetPlayerTeamPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetPlayerTeamPacket;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
public class ClientboundSetPlayerTeamPacketTest extends PacketTest {
|
public class ClientboundSetPlayerTeamPacketTest extends PacketTest {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
// Test nameTagVisibility and collisionRule encoding/decoding
|
// Test nameTagVisibility and collisionRule encoding/decoding
|
||||||
this.setPackets(
|
this.setPackets(
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.github.steveice10.mc.protocol.packet.login.clientbound;
|
package com.github.steveice10.mc.protocol.packet.login.clientbound;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class ClientboundCustomQueryPacketTest extends PacketTest {
|
public class ClientboundCustomQueryPacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
byte[] data = new byte[1024];
|
byte[] data = new byte[1024];
|
||||||
new Random().nextBytes(data);
|
new Random().nextBytes(data);
|
||||||
|
|
|
@ -2,12 +2,12 @@ package com.github.steveice10.mc.protocol.packet.login.clientbound;
|
||||||
|
|
||||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ClientboundGameProfilePacketTest extends PacketTest {
|
public class ClientboundGameProfilePacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(new ClientboundGameProfilePacket(new GameProfile(UUID.randomUUID(), "Username")));
|
this.setPackets(new ClientboundGameProfilePacket(new GameProfile(UUID.randomUUID(), "Username")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.github.steveice10.mc.protocol.packet.login.clientbound;
|
package com.github.steveice10.mc.protocol.packet.login.clientbound;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import java.security.KeyPair;
|
import java.security.KeyPair;
|
||||||
import java.security.KeyPairGenerator;
|
import java.security.KeyPairGenerator;
|
||||||
|
@ -9,7 +9,7 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class ClientboundHelloPacketTest extends PacketTest {
|
public class ClientboundHelloPacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
KeyPair keyPair;
|
KeyPair keyPair;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.github.steveice10.mc.protocol.packet.login.clientbound;
|
package com.github.steveice10.mc.protocol.packet.login.clientbound;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
public class ClientboundLoginCompressionPacketTest extends PacketTest {
|
public class ClientboundLoginCompressionPacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(new ClientboundLoginCompressionPacket(1));
|
this.setPackets(new ClientboundLoginCompressionPacket(1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@ package com.github.steveice10.mc.protocol.packet.login.clientbound;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
public class ClientboundLoginDisconnectPacketTest extends PacketTest {
|
public class ClientboundLoginDisconnectPacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(new ClientboundLoginDisconnectPacket("Message"),
|
this.setPackets(new ClientboundLoginDisconnectPacket("Message"),
|
||||||
new ClientboundLoginDisconnectPacket(Component.text("Message")));
|
new ClientboundLoginDisconnectPacket(Component.text("Message")));
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.github.steveice10.mc.protocol.packet.login.serverbound;
|
package com.github.steveice10.mc.protocol.packet.login.serverbound;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class ServerboundCustomQueryAnswerPacketTest extends PacketTest {
|
public class ServerboundCustomQueryAnswerPacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
byte[] data = new byte[1024];
|
byte[] data = new byte[1024];
|
||||||
new Random().nextBytes(data);
|
new Random().nextBytes(data);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.github.steveice10.mc.protocol.packet.login.serverbound;
|
package com.github.steveice10.mc.protocol.packet.login.serverbound;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ServerboundHelloPacketTest extends PacketTest {
|
public class ServerboundHelloPacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(new ServerboundHelloPacket("Username", UUID.randomUUID()));
|
this.setPackets(new ServerboundHelloPacket("Username", UUID.randomUUID()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.github.steveice10.mc.protocol.packet.login.serverbound;
|
package com.github.steveice10.mc.protocol.packet.login.serverbound;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import javax.crypto.KeyGenerator;
|
import javax.crypto.KeyGenerator;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
|
@ -11,8 +11,7 @@ import java.security.KeyPairGenerator;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class ServerboundKeyPacketTest extends PacketTest {
|
public class ServerboundKeyPacketTest extends PacketTest {
|
||||||
private KeyPair keyPair;
|
private KeyPair keyPair;
|
||||||
|
@ -20,7 +19,7 @@ public class ServerboundKeyPacketTest extends PacketTest {
|
||||||
private ServerboundKeyPacket packet;
|
private ServerboundKeyPacket packet;
|
||||||
private byte[] verifyToken;
|
private byte[] verifyToken;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
try {
|
try {
|
||||||
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
|
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
|
||||||
|
@ -43,7 +42,7 @@ public class ServerboundKeyPacketTest extends PacketTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncryptionResponsePacketGetters() {
|
public void testEncryptionResponsePacketGetters() {
|
||||||
assertEquals("Secret key does not match.", this.secretKey, this.packet.getSecretKey(this.keyPair.getPrivate()));
|
assertEquals(this.secretKey, this.packet.getSecretKey(this.keyPair.getPrivate()), "Secret key does not match.");
|
||||||
assertArrayEquals("Verify token does not match.", this.verifyToken, this.packet.getEncryptedChallenge(this.keyPair.getPrivate()));
|
assertArrayEquals(this.verifyToken, this.packet.getEncryptedChallenge(this.keyPair.getPrivate()), "Verify token does not match.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.github.steveice10.mc.protocol.packet.status.clientbound;
|
package com.github.steveice10.mc.protocol.packet.status.clientbound;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
public class ClientboundPongResponsePacketTest extends PacketTest {
|
public class ClientboundPongResponsePacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(new ClientboundPongResponsePacket(System.currentTimeMillis()));
|
this.setPackets(new ClientboundPongResponsePacket(System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,14 @@ import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo;
|
||||||
import com.github.steveice10.mc.protocol.data.status.VersionInfo;
|
import com.github.steveice10.mc.protocol.data.status.VersionInfo;
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ClientboundStatusResponsePacketTest extends PacketTest {
|
public class ClientboundStatusResponsePacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(new ClientboundStatusResponsePacket(
|
this.setPackets(new ClientboundStatusResponsePacket(
|
||||||
new ServerStatusInfo(
|
new ServerStatusInfo(
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.github.steveice10.mc.protocol.packet.status.serverbound;
|
package com.github.steveice10.mc.protocol.packet.status.serverbound;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
public class ServerboundPingRequestPacketTest extends PacketTest {
|
public class ServerboundPingRequestPacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(new ServerboundPingRequestPacket(System.currentTimeMillis()));
|
this.setPackets(new ServerboundPingRequestPacket(System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.github.steveice10.mc.protocol.packet.status.serverbound;
|
package com.github.steveice10.mc.protocol.packet.status.serverbound;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
public class ServerboundStatusRequestPacketTest extends PacketTest {
|
public class ServerboundStatusRequestPacketTest extends PacketTest {
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPackets(new ServerboundStatusRequestPacket());
|
this.setPackets(new ServerboundStatusRequestPacket());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue