Update dependencies (#763)

* Update dependencies

* Use static imports for Assertions

* Change commit hash from jitpack
This commit is contained in:
Alex 2023-11-23 08:22:23 +01:00 committed by GitHub
parent 6f53d57f8d
commit 64d58248d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 124 additions and 125 deletions

View file

@ -55,4 +55,4 @@ Please join [the GeyserMC Discord server](https://discord.gg/geysermc) and visit
## 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
View file

@ -10,7 +10,7 @@
<name>MCProtocolLib</name>
<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>
<connection>scm:git:git@github.com:GeyserMC/MCProtocolLib.git</connection>
@ -20,15 +20,15 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.8</jdk.version>
<adventure.version>4.9.3</adventure.version>
<argLine></argLine>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<adventure.version>4.14.0</adventure.version>
</properties>
<licenses>
<license>
<name>MIT</name>
<url>http://www.opensource.org/licenses/mit-license.html</url>
<url>https://opensource.org/license/mit/</url>
<distribution>repo</distribution>
</license>
</licenses>
@ -81,6 +81,7 @@
</repositories>
<dependencies>
<!-- Minecraft related libraries -->
<dependency>
<groupId>com.github.steveice10</groupId>
<artifactId>opennbt</artifactId>
@ -90,9 +91,10 @@
<dependency>
<groupId>com.github.GeyserMC</groupId>
<artifactId>mcauthlib</artifactId>
<version>6f3d6aada5</version>
<version>6621fd081c</version>
<scope>compile</scope>
</dependency>
<!-- Kyori adventure -->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson</artifactId>
@ -105,12 +107,20 @@
<version>${adventure.version}</version>
<scope>compile</scope>
</dependency>
<!-- Lombok and annotations -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>4.7.3</version>
<scope>provided</scope>
</dependency>
<!-- Math utilities -->
<dependency>
<groupId>org.cloudburstmc.math</groupId>
<artifactId>api</artifactId>
@ -123,48 +133,45 @@
<version>2.0</version>
<scope>compile</scope>
</dependency>
<!-- Stripped down fastutil -->
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-object-int-maps</artifactId>
<version>8.5.2</version>
<version>8.5.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-int-object-maps</artifactId>
<version>8.5.3</version>
<scope>compile</scope>
</dependency>
<!-- Netty -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.66.Final</version>
<version>4.1.99.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-haproxy</artifactId>
<version>4.1.66.Final</version>
<version>4.1.99.Final</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.netty.incubator</groupId>
<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>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>4.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-int-object-maps</artifactId>
<version>8.5.2</version>
<scope>compile</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
@ -174,40 +181,32 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<version>3.3.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
<version>3.11.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<!-- Force the right file encoding during unit testing -->
<argLine>-Dfile.encoding=${project.build.sourceEncoding} @{argLine}</argLine>
</configuration>
<version>3.1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<version>3.6.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
@ -225,7 +224,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
@ -238,12 +237,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<version>3.1.1</version>
</plugin>
</plugins>
</build>

View file

@ -1,7 +1,7 @@
package com.github.steveice10.mc.protocol.data;
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 {
private static GsonComponentSerializer serializer = GsonComponentSerializer.builder()

View file

@ -7,5 +7,5 @@ import lombok.NonNull;
@Data
@AllArgsConstructor
public class BreakBlockEventData implements LevelEventData {
private final @NonNull int blockState;
private final int blockState;
}

View file

@ -74,7 +74,6 @@ public interface Server {
* @return Value of the flag.
* @throws IllegalStateException If the flag's value isn't of the required type.
*/
@SuppressWarnings("unchecked")
<T> T getGlobalFlag(String key, T def);
/**
@ -116,6 +115,8 @@ public interface Server {
/**
* Binds the listener to its host and port.
*
* @return The server.
*/
AbstractServer bind();
@ -123,6 +124,7 @@ public interface Server {
* Binds the listener to its host and port.
*
* @param wait Whether to wait for the listener to finish binding.
* @return The server.
*/
AbstractServer bind(boolean wait);
@ -131,6 +133,7 @@ public interface Server {
*
* @param wait Whether to wait for the listener to finish binding.
* @param callback Callback to call when the listener has finished binding.
* @return The server.
*/
AbstractServer bind(boolean wait, Runnable callback);

View file

@ -17,9 +17,9 @@ import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.tcp.TcpClientSession;
import com.github.steveice10.packetlib.tcp.TcpServer;
import net.kyori.adventure.text.Component;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
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.VERIFY_USERS_KEY;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.*;
public class MinecraftProtocolTest {
private static final String HOST = "localhost";
@ -49,7 +47,7 @@ public class MinecraftProtocolTest {
private static Server server;
@BeforeClass
@BeforeAll
public static void setupServer() {
server = new TcpServer(HOST, PORT, MinecraftProtocol::new);
server.setGlobalFlag(VERIFY_USERS_KEY, false);
@ -66,10 +64,10 @@ public class MinecraftProtocolTest {
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() {
if (server != null) {
server.close(true);
@ -87,8 +85,8 @@ public class MinecraftProtocolTest {
session.connect();
handler.status.await(4, SECONDS);
assertNotNull("Failed to get server info.", handler.info);
assertEquals("Received incorrect server info.", SERVER_INFO, handler.info);
assertNotNull(handler.info, "Failed to get server info.");
assertEquals(SERVER_INFO, handler.info, "Received incorrect server info.");
} finally {
session.disconnect("Status test complete.");
}
@ -104,8 +102,8 @@ public class MinecraftProtocolTest {
session.connect();
listener.login.await(4, SECONDS);
assertNotNull("Failed to log in.", listener.packet);
assertEquals("Received incorrect join packet.", JOIN_GAME_PACKET, listener.packet);
assertNotNull(listener.packet, "Failed to log in.");
assertEquals(JOIN_GAME_PACKET, listener.packet, "Received incorrect join packet.");
} finally {
session.disconnect("Login test complete.");
}

View file

@ -8,19 +8,21 @@ import com.github.steveice10.mc.protocol.data.game.chunk.palette.SingletonPalett
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class ChunkTest {
private final List<ChunkSection> chunkSectionsToTest = new ArrayList<>();
@Before
@BeforeEach
public void setup() {
chunkSectionsToTest.add(new ChunkSection());
@ -49,7 +51,8 @@ public class ChunkTest {
e.printStackTrace();
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() {
for (ChunkSection section : chunkSectionsToTest) {
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);
Assert.assertNotEquals("Deep copy is not deep: " + section + " vs " + copy, section, copy);
assertNotEquals(section, copy, "Deep copy is not deep: " + section + " vs " + copy);
}
}
}

View file

@ -5,11 +5,12 @@ import com.github.steveice10.mc.protocol.data.game.entity.Effect;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Miscellaneous tests for reading and writing classes to/from the network
*/
@ -22,7 +23,7 @@ public class NetworkDataTests {
ByteBuf buf = Unpooled.buffer();
helper.writeEffect(buf, effect);
Assert.assertEquals(effect, helper.readEffect(buf));
assertEquals(effect, helper.readEffect(buf));
}
}
}

View file

@ -6,12 +6,12 @@ import com.github.steveice10.packetlib.packet.Packet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Constructor;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public abstract class PacketTest {
private MinecraftPacket[] packets;
@ -29,7 +29,7 @@ public abstract class PacketTest {
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);
}
}

View file

@ -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.data.handshake.HandshakeIntent;
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.List;
public class ClientIntentionPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
List<MinecraftPacket> packets = new ArrayList<>();
for (HandshakeIntent intent : HandshakeIntent.values()) {

View file

@ -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.StringProperties;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import java.util.OptionalInt;
public class ClientboundCommandsPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(new ClientboundCommandsPacket(
new CommandNode[]{

View file

@ -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.Recipe;
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.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.data.game.recipe.data.*;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
public class ServerDeclareRecipesTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(
new ClientboundUpdateRecipesPacket(

View file

@ -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.packet.PacketTest;
import org.cloudburstmc.math.vector.Vector3i;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
public class ClientboundBlockUpdatePacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(
new ClientboundBlockUpdatePacket(new BlockChangeEntry(

View file

@ -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.packet.PacketTest;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import java.io.IOException;
import java.util.BitSet;
import java.util.Collections;
public class ClientboundLevelChunkWithLightPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() throws IOException {
this.setPackets(
new ClientboundLevelChunkWithLightPacket(0, 0,
@ -26,4 +26,4 @@ public class ClientboundLevelChunkWithLightPacketTest extends PacketTest {
)
);
}
}
}

View file

@ -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.packet.PacketTest;
import org.cloudburstmc.math.vector.Vector3i;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
public class ClientboundSectionBlocksUpdatePacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(
new ClientboundSectionBlocksUpdatePacket(3, 4, 12, new BlockChangeEntry(Vector3i.from(50, 65, 200), 3))

View file

@ -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.ingame.clientbound.entity.ClientboundSetEntityDataPacket;
import org.cloudburstmc.math.vector.Vector3i;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import java.util.OptionalInt;
public class ClientboundSetEntityDataPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(
new ClientboundSetEntityDataPacket(0, new EntityMetadata[0]),

View file

@ -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.packet.PacketTest;
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 {
@Before
@BeforeEach
public void setup() {
this.setPackets(
new ClientboundSetEquipmentPacket(1, new Equipment[]{

View file

@ -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.ingame.clientbound.scoreboard.ClientboundSetPlayerTeamPacket;
import net.kyori.adventure.text.Component;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
public class ClientboundSetPlayerTeamPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
// Test nameTagVisibility and collisionRule encoding/decoding
this.setPackets(

View file

@ -1,12 +1,12 @@
package com.github.steveice10.mc.protocol.packet.login.clientbound;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import java.util.Random;
public class ClientboundCustomQueryPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
byte[] data = new byte[1024];
new Random().nextBytes(data);

View file

@ -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.protocol.packet.PacketTest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import java.util.UUID;
public class ClientboundGameProfilePacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(new ClientboundGameProfilePacket(new GameProfile(UUID.randomUUID(), "Username")));
}

View file

@ -1,7 +1,7 @@
package com.github.steveice10.mc.protocol.packet.login.clientbound;
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.KeyPairGenerator;
@ -9,7 +9,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.Random;
public class ClientboundHelloPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
KeyPair keyPair;
try {

View file

@ -1,10 +1,10 @@
package com.github.steveice10.mc.protocol.packet.login.clientbound;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
public class ClientboundLoginCompressionPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(new ClientboundLoginCompressionPacket(1));
}

View file

@ -2,10 +2,10 @@ package com.github.steveice10.mc.protocol.packet.login.clientbound;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import net.kyori.adventure.text.Component;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
public class ClientboundLoginDisconnectPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(new ClientboundLoginDisconnectPacket("Message"),
new ClientboundLoginDisconnectPacket(Component.text("Message")));

View file

@ -1,12 +1,12 @@
package com.github.steveice10.mc.protocol.packet.login.serverbound;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import java.util.Random;
public class ServerboundCustomQueryAnswerPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
byte[] data = new byte[1024];
new Random().nextBytes(data);

View file

@ -1,12 +1,12 @@
package com.github.steveice10.mc.protocol.packet.login.serverbound;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import java.util.UUID;
public class ServerboundHelloPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(new ServerboundHelloPacket("Username", UUID.randomUUID()));
}

View file

@ -1,8 +1,8 @@
package com.github.steveice10.mc.protocol.packet.login.serverbound;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
@ -11,8 +11,7 @@ import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
public class ServerboundKeyPacketTest extends PacketTest {
private KeyPair keyPair;
@ -20,7 +19,7 @@ public class ServerboundKeyPacketTest extends PacketTest {
private ServerboundKeyPacket packet;
private byte[] verifyToken;
@Before
@BeforeEach
public void setup() {
try {
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
@ -43,7 +42,7 @@ public class ServerboundKeyPacketTest extends PacketTest {
@Test
public void testEncryptionResponsePacketGetters() {
assertEquals("Secret key does not match.", this.secretKey, this.packet.getSecretKey(this.keyPair.getPrivate()));
assertArrayEquals("Verify token does not match.", this.verifyToken, this.packet.getEncryptedChallenge(this.keyPair.getPrivate()));
assertEquals(this.secretKey, this.packet.getSecretKey(this.keyPair.getPrivate()), "Secret key does not match.");
assertArrayEquals(this.verifyToken, this.packet.getEncryptedChallenge(this.keyPair.getPrivate()), "Verify token does not match.");
}
}

View file

@ -1,10 +1,10 @@
package com.github.steveice10.mc.protocol.packet.status.clientbound;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
public class ClientboundPongResponsePacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(new ClientboundPongResponsePacket(System.currentTimeMillis()));
}

View file

@ -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.packet.PacketTest;
import net.kyori.adventure.text.Component;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import java.util.ArrayList;
import java.util.Collections;
import java.util.UUID;
public class ClientboundStatusResponsePacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(new ClientboundStatusResponsePacket(
new ServerStatusInfo(

View file

@ -1,10 +1,10 @@
package com.github.steveice10.mc.protocol.packet.status.serverbound;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
public class ServerboundPingRequestPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(new ServerboundPingRequestPacket(System.currentTimeMillis()));
}

View file

@ -1,10 +1,10 @@
package com.github.steveice10.mc.protocol.packet.status.serverbound;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
public class ServerboundStatusRequestPacketTest extends PacketTest {
@Before
@BeforeEach
public void setup() {
this.setPackets(new ServerboundStatusRequestPacket());
}