diff --git a/libs.gradle b/libs.gradle
index 402450a..d1b57c1 100644
--- a/libs.gradle
+++ b/libs.gradle
@@ -13,8 +13,6 @@ ext {
lombok : 'org.projectlombok:lombok:1.18.12',
annotations: 'com.google.code.findbugs:jsr305:3.0.2',
lang3 : 'org.apache.commons:commons-lang3:3.11',
- netty : ["io.netty:netty-transport:${netty_version}",
- "io.netty:netty-handler:${netty_version}"],
reactor : 'io.projectreactor:reactor-core:3.4.5',
yaml : 'org.yaml:snakeyaml:1.28',
json : 'com.eclipsesource.minimal-json:minimal-json:0.9.5',
@@ -23,6 +21,11 @@ ext {
objpool : 'org.apache.commons:commons-pool2:2.9.0'
]
+ libs.netty = [
+ transport: "io.netty:netty-transport:${netty_version}",
+ handler : "io.netty:netty-handler:${netty_version}"
+ ]
+
libs.logger = [
slf4j : ["org.slf4j:slf4j-api:${slf4j_version}",
"org.slf4j:jcl-over-slf4j:${slf4j_version}"],
diff --git a/logic.gradle b/logic.gradle
index 68886aa..a3eb9c6 100644
--- a/logic.gradle
+++ b/logic.gradle
@@ -1,6 +1,7 @@
//file:noinspection GrUnresolvedAccess
apply plugin: 'java'
apply plugin: 'java-library'
+apply plugin: 'jacoco'
apply from: rootDir.toPath().resolve('libs.gradle').toFile()
String getProperty1(String propertyName1, String propertyName2) {
@@ -41,3 +42,7 @@ dependencies {
test {
useJUnitPlatform()
}
+
+jacoco {
+ toolVersion = '0.8.7'
+}
diff --git a/protocol-new/build.gradle b/protocol-new/build.gradle
index 8a76049..031565b 100644
--- a/protocol-new/build.gradle
+++ b/protocol-new/build.gradle
@@ -1,4 +1,7 @@
apply from: rootDir.toPath().resolve('logic.gradle').toFile()
dependencies {
+ implementation libs.netty.transport
+
+ testImplementation libs.lang3
}
diff --git a/protocol/src/main/java/mc/protocol/io/NetByteBuf.java b/protocol-new/src/main/java/mc/protocol/io/NetByteBuf.java
similarity index 92%
rename from protocol/src/main/java/mc/protocol/io/NetByteBuf.java
rename to protocol-new/src/main/java/mc/protocol/io/NetByteBuf.java
index b76ba17..7f21e4e 100644
--- a/protocol/src/main/java/mc/protocol/io/NetByteBuf.java
+++ b/protocol-new/src/main/java/mc/protocol/io/NetByteBuf.java
@@ -32,8 +32,6 @@ import java.util.UUID;
* | | | | этого числа). |
* | VarInt | >= 1 ; <= 5 | Число от -2147483648 и 2147483647 | 32-bit число с плавающей размерностью от 1 до 5 байт |
* | VarLong | >= 1 ; <= 10 | Число от -9223372036854775808 и 9223372036854775807 | 64-bit число с плавающей размерностью от 1 до 10 байт |
- * | Position | 8 | 64-bit число разделённое на три части: x, y, z | Кодируется формулой: |
- * | | | | ((x & 0x3FFFFFF) << 38) | ((y & 0xFFF) << 26) | (z & 0x3FFFFFF) |
*
* [1] - Single-precision floating-point format
* [2] - Double-precision floating-point format
@@ -67,9 +65,9 @@ public class NetByteBuf extends ByteBuf {
if (length == 0) {
return "";
} else if (length > maxLength) {
- throw new DecoderException("String length exceeds maximum length: " + length + " > " + maxLength);
+ throw new NetIOException("String length exceeds maximum length: " + length + " > " + maxLength);
} else if (length < 0) {
- throw new DecoderException("String length less zero!");
+ throw new NetIOException("String length less zero!");
}
byte[] bytes = new byte[length * 4];
diff --git a/protocol-new/src/main/java/mc/protocol/io/NetIOException.java b/protocol-new/src/main/java/mc/protocol/io/NetIOException.java
new file mode 100644
index 0000000..e7ac872
--- /dev/null
+++ b/protocol-new/src/main/java/mc/protocol/io/NetIOException.java
@@ -0,0 +1,8 @@
+package mc.protocol.io;
+
+public class NetIOException extends RuntimeException {
+
+ public NetIOException(String message) {
+ super(message);
+ }
+}
diff --git a/protocol/src/test/java/mc/protocol/io/NetByteBufReadTest.java b/protocol-new/src/test/java/mc/protocol/io/NetByteBufReadTest.java
similarity index 97%
rename from protocol/src/test/java/mc/protocol/io/NetByteBufReadTest.java
rename to protocol-new/src/test/java/mc/protocol/io/NetByteBufReadTest.java
index 6337ec5..95f724c 100644
--- a/protocol/src/test/java/mc/protocol/io/NetByteBufReadTest.java
+++ b/protocol-new/src/test/java/mc/protocol/io/NetByteBufReadTest.java
@@ -16,7 +16,6 @@ import java.util.UUID;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.*;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
class NetByteBufReadTest {
@@ -108,7 +107,7 @@ class NetByteBufReadTest {
NetByteBuf netByteBuf = new NetByteBuf(Unpooled.wrappedBuffer(baos.toByteArray()));
- assertThrows(DecoderException.class, () -> netByteBuf.readString(length));
+ assertThrows(NetIOException.class, () -> netByteBuf.readString(length));
}
@Test
@@ -127,7 +126,7 @@ class NetByteBufReadTest {
NetByteBuf netByteBuf = new NetByteBuf(Unpooled.wrappedBuffer(baos.toByteArray()));
- assertThrows(DecoderException.class, () -> netByteBuf.readString(-1));
+ assertThrows(NetIOException.class, () -> netByteBuf.readString(-1));
}
@ParameterizedTest
diff --git a/protocol/src/test/java/mc/protocol/io/NetByteBufWriteTest.java b/protocol-new/src/test/java/mc/protocol/io/NetByteBufWriteTest.java
similarity index 97%
rename from protocol/src/test/java/mc/protocol/io/NetByteBufWriteTest.java
rename to protocol-new/src/test/java/mc/protocol/io/NetByteBufWriteTest.java
index 3386041..a16ef3a 100644
--- a/protocol/src/test/java/mc/protocol/io/NetByteBufWriteTest.java
+++ b/protocol-new/src/test/java/mc/protocol/io/NetByteBufWriteTest.java
@@ -48,6 +48,16 @@ class NetByteBufWriteTest {
assertEquals(expectedByte, byteBuf.array()[0]);
}
+ @Test
+ void writeUnsignedByte() {
+ ByteBuf byteBuf = Unpooled.buffer();
+ NetByteBuf netByteBuf = new NetByteBuf(byteBuf);
+
+ netByteBuf.writeUnsignedByte(129);
+
+ assertEquals(129, netByteBuf.readUnsignedByte());
+ }
+
@ParameterizedTest
@MethodSource("paramsWriteString")
void writeString(String string, int exceptedLength) {
diff --git a/protocol/src/main/java/mc/protocol/io/DecoderException.java b/protocol/src/main/java/mc/protocol/io/DecoderException.java
deleted file mode 100644
index a30ee19..0000000
--- a/protocol/src/main/java/mc/protocol/io/DecoderException.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package mc.protocol.io;
-
-public class DecoderException extends RuntimeException {
-
- public DecoderException(String message) {
- super(message);
- }
-}