diff --git a/build.gradle.kts b/build.gradle.kts index 56e2308b..c4b3a703 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -79,6 +79,9 @@ dependencies { // Netty api(libs.bundles.netty) + // Checker Framework + api(libs.checkerframework.qual) + // Test dependencies testImplementation(libs.junit.jupiter) } diff --git a/example/src/main/java/com/github/steveice10/mc/protocol/test/MinecraftProtocolTest.java b/example/src/main/java/com/github/steveice10/mc/protocol/test/MinecraftProtocolTest.java index df06fffa..efa2d1a0 100644 --- a/example/src/main/java/com/github/steveice10/mc/protocol/test/MinecraftProtocolTest.java +++ b/example/src/main/java/com/github/steveice10/mc/protocol/test/MinecraftProtocolTest.java @@ -38,9 +38,11 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; import java.net.Proxy; +import java.nio.charset.StandardCharsets; import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; +import java.util.Base64; import java.util.BitSet; public class MinecraftProtocolTest { @@ -157,7 +159,7 @@ public class MinecraftProtocolTest { + " / " + info.getPlayerInfo().getMaxPlayers()); System.out.println("Players: " + Arrays.toString(info.getPlayerInfo().getPlayers().toArray())); System.out.println("Description: " + info.getDescription()); - System.out.println("Icon: " + info.getIconPng()); + System.out.println("Icon: " + new String(Base64.getEncoder().encode(info.getIconPng()), StandardCharsets.UTF_8)); }); client.setFlag(MinecraftConstants.SERVER_PING_TIME_HANDLER_KEY, (ServerPingTimeHandler) (session, pingTime) -> diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index eb37d097..80c8234b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,6 +12,7 @@ math = "2.0" fastutil-maps = "8.5.3" netty = "4.1.103.Final" netty-io_uring = "0.0.24.Final" +checkerframework = "3.42.0" junit = "5.8.2" [libraries] @@ -27,10 +28,13 @@ math-immutable = { module = "org.cloudburstmc.math:immutable", version.ref = "ma fastutil-object2int-maps = { module = "com.nukkitx.fastutil:fastutil-object-int-maps", version.ref = "fastutil-maps" } fastutil-int2object-maps = { module = "com.nukkitx.fastutil:fastutil-int-object-maps", version.ref = "fastutil-maps" } +fastutil-int2int-maps = { module = "com.nukkitx.fastutil:fastutil-int-int-maps", version.ref = "fastutil-maps" } netty-all = { module = "io.netty:netty-all", version.ref = "netty" } netty-incubator-transport-native-io_uring = { module = "io.netty.incubator:netty-incubator-transport-native-io_uring", version.ref = "netty-io_uring" } +checkerframework-qual = { module = "org.checkerframework:checker-qual", version.ref = "checkerframework" } + junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" } [plugins] @@ -44,5 +48,5 @@ lombok = { id = "io.freefair.lombok", version.ref = "lombok-plugin" } adventure = ["adventure-text-serializer-gson", "adventure-text-serializer-json-legacy-impl"] math = ["math-api", "math-immutable"] -fastutil = ["fastutil-object2int-maps", "fastutil-int2object-maps"] +fastutil = ["fastutil-object2int-maps", "fastutil-int2object-maps", "fastutil-int2int-maps"] netty = ["netty-all", "netty-incubator-transport-native-io_uring"] diff --git a/lombok.config b/lombok.config new file mode 100644 index 00000000..27da8258 --- /dev/null +++ b/lombok.config @@ -0,0 +1 @@ +lombok.addNullAnnotations = checkerframework diff --git a/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java b/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java index 22d66912..2e3711dc 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java +++ b/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java @@ -54,7 +54,7 @@ public class ClientListener extends SessionAdapter { public void packetReceived(Session session, Packet packet) { MinecraftProtocol protocol = (MinecraftProtocol) session.getPacketProtocol(); if (protocol.getState() == ProtocolState.LOGIN) { - if (packet instanceof ClientboundHelloPacket) { + if (packet instanceof ClientboundHelloPacket helloPacket) { GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY); String accessToken = session.getFlag(MinecraftConstants.ACCESS_TOKEN_KEY); @@ -62,7 +62,6 @@ public class ClientListener extends SessionAdapter { throw new UnexpectedEncryptionException(); } - ClientboundHelloPacket helloPacket = (ClientboundHelloPacket) packet; SecretKey key; try { KeyGenerator gen = KeyGenerator.getInstance("AES"); @@ -91,22 +90,22 @@ public class ClientListener extends SessionAdapter { session.enableEncryption(protocol.enableEncryption(key)); } else if (packet instanceof ClientboundGameProfilePacket) { session.send(new ServerboundLoginAcknowledgedPacket()); - } else if (packet instanceof ClientboundLoginDisconnectPacket) { - session.disconnect(((ClientboundLoginDisconnectPacket) packet).getReason()); - } else if (packet instanceof ClientboundLoginCompressionPacket) { - session.setCompressionThreshold(((ClientboundLoginCompressionPacket) packet).getThreshold(), false); + } else if (packet instanceof ClientboundLoginDisconnectPacket loginDisconnectPacket) { + session.disconnect(loginDisconnectPacket.getReason()); + } else if (packet instanceof ClientboundLoginCompressionPacket loginCompressionPacket) { + session.setCompressionThreshold(loginCompressionPacket.getThreshold(), false); } } else if (protocol.getState() == ProtocolState.STATUS) { - if (packet instanceof ClientboundStatusResponsePacket) { - ServerStatusInfo info = ((ClientboundStatusResponsePacket) packet).getInfo(); + if (packet instanceof ClientboundStatusResponsePacket statusResponsePacket) { + ServerStatusInfo info = statusResponsePacket.getInfo(); ServerInfoHandler handler = session.getFlag(MinecraftConstants.SERVER_INFO_HANDLER_KEY); if (handler != null) { handler.handle(session, info); } session.send(new ServerboundPingRequestPacket(System.currentTimeMillis())); - } else if (packet instanceof ClientboundPongResponsePacket) { - long time = System.currentTimeMillis() - ((ClientboundPongResponsePacket) packet).getPingTime(); + } else if (packet instanceof ClientboundPongResponsePacket pongResponsePacket) { + long time = System.currentTimeMillis() - pongResponsePacket.getPingTime(); ServerPingTimeHandler handler = session.getFlag(MinecraftConstants.SERVER_PING_TIME_HANDLER_KEY); if (handler != null) { handler.handle(session, time); @@ -115,10 +114,10 @@ public class ClientListener extends SessionAdapter { session.disconnect("Finished"); } } else if (protocol.getState() == ProtocolState.GAME) { - if (packet instanceof ClientboundKeepAlivePacket && session.getFlag(MinecraftConstants.AUTOMATIC_KEEP_ALIVE_MANAGEMENT, true)) { - session.send(new ServerboundKeepAlivePacket(((ClientboundKeepAlivePacket) packet).getPingId())); - } else if (packet instanceof ClientboundDisconnectPacket) { - session.disconnect(((ClientboundDisconnectPacket) packet).getReason()); + if (packet instanceof ClientboundKeepAlivePacket keepAlivePacket && session.getFlag(MinecraftConstants.AUTOMATIC_KEEP_ALIVE_MANAGEMENT, true)) { + session.send(new ServerboundKeepAlivePacket(keepAlivePacket.getPingId())); + } else if (packet instanceof ClientboundDisconnectPacket disconnectPacket) { + session.disconnect(disconnectPacket.getReason()); } else if (packet instanceof ClientboundStartConfigurationPacket) { session.send(new ServerboundConfigurationAcknowledgedPacket()); } @@ -154,10 +153,15 @@ public class ClientListener extends SessionAdapter { @Override public void connected(ConnectedEvent event) { MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); - if (this.targetState == ProtocolState.LOGIN) { - event.getSession().send(new ClientIntentionPacket(protocol.getCodec().getProtocolVersion(), event.getSession().getHost(), event.getSession().getPort(), HandshakeIntent.LOGIN)); - } else if (this.targetState == ProtocolState.STATUS) { - event.getSession().send(new ClientIntentionPacket(protocol.getCodec().getProtocolVersion(), event.getSession().getHost(), event.getSession().getPort(), HandshakeIntent.STATUS)); - } + event.getSession().send(new ClientIntentionPacket( + protocol.getCodec().getProtocolVersion(), + event.getSession().getHost(), + event.getSession().getPort(), + switch (this.targetState) { + case LOGIN -> HandshakeIntent.LOGIN; + case STATUS -> HandshakeIntent.STATUS; + default -> throw new IllegalArgumentException("Invalid target state: " + this.targetState); + } + )); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java b/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java index 1f076c99..9768fcf1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java +++ b/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java @@ -21,7 +21,7 @@ import io.netty.buffer.ByteBuf; import lombok.Getter; import lombok.NonNull; import lombok.Setter; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.DataInput; import java.io.DataInputStream; diff --git a/src/main/java/com/github/steveice10/mc/protocol/ServerListener.java b/src/main/java/com/github/steveice10/mc/protocol/ServerListener.java index 9144830d..59e4ef82 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/ServerListener.java +++ b/src/main/java/com/github/steveice10/mc/protocol/ServerListener.java @@ -33,6 +33,7 @@ import com.github.steveice10.packetlib.event.session.ConnectedEvent; import com.github.steveice10.packetlib.event.session.DisconnectingEvent; import com.github.steveice10.packetlib.event.session.SessionAdapter; import com.github.steveice10.packetlib.packet.Packet; +import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.Component; import javax.crypto.SecretKey; @@ -87,36 +88,31 @@ public class ServerListener extends SessionAdapter { public void packetReceived(Session session, Packet packet) { MinecraftProtocol protocol = (MinecraftProtocol) session.getPacketProtocol(); if (protocol.getState() == ProtocolState.HANDSHAKE) { - if (packet instanceof ClientIntentionPacket) { - ClientIntentionPacket intentionPacket = (ClientIntentionPacket) packet; + if (packet instanceof ClientIntentionPacket intentionPacket) { switch (intentionPacket.getIntent()) { - case STATUS: - protocol.setState(ProtocolState.STATUS); - break; - case LOGIN: + case STATUS -> protocol.setState(ProtocolState.STATUS); + case LOGIN -> { protocol.setState(ProtocolState.LOGIN); if (intentionPacket.getProtocolVersion() > protocol.getCodec().getProtocolVersion()) { session.disconnect("Outdated server! I'm still on " + protocol.getCodec().getMinecraftVersion() + "."); } else if (intentionPacket.getProtocolVersion() < protocol.getCodec().getProtocolVersion()) { session.disconnect("Outdated client! Please use " + protocol.getCodec().getMinecraftVersion() + "."); } - - break; - default: - throw new UnsupportedOperationException("Invalid client intent: " + intentionPacket.getIntent()); + } + default -> + throw new UnsupportedOperationException("Invalid client intent: " + intentionPacket.getIntent()); } } } else if (protocol.getState() == ProtocolState.LOGIN) { - if (packet instanceof ServerboundHelloPacket) { - this.username = ((ServerboundHelloPacket) packet).getUsername(); + if (packet instanceof ServerboundHelloPacket helloPacket) { + this.username = helloPacket.getUsername(); if (session.getFlag(MinecraftConstants.VERIFY_USERS_KEY, true)) { session.send(new ClientboundHelloPacket(SERVER_ID, KEY_PAIR.getPublic(), this.challenge)); } else { new Thread(new UserAuthTask(session, null)).start(); } - } else if (packet instanceof ServerboundKeyPacket) { - ServerboundKeyPacket keyPacket = (ServerboundKeyPacket) packet; + } else if (packet instanceof ServerboundKeyPacket keyPacket) { PrivateKey privateKey = KEY_PAIR.getPrivate(); if (!Arrays.equals(this.challenge, keyPacket.getEncryptedChallenge(privateKey))) { @@ -147,19 +143,19 @@ public class ServerListener extends SessionAdapter { ServerStatusInfo info = builder.buildInfo(session); session.send(new ClientboundStatusResponsePacket(info)); - } else if (packet instanceof ServerboundPingRequestPacket) { - session.send(new ClientboundPongResponsePacket(((ServerboundPingRequestPacket) packet).getPingTime())); + } else if (packet instanceof ServerboundPingRequestPacket pingRequestPacket) { + session.send(new ClientboundPongResponsePacket(pingRequestPacket.getPingTime())); } } else if (protocol.getState() == ProtocolState.GAME) { - if (packet instanceof ServerboundKeepAlivePacket) { - if (((ServerboundKeepAlivePacket) packet).getPingId() == this.lastPingId) { + if (packet instanceof ServerboundKeepAlivePacket keepAlivePacket) { + if (keepAlivePacket.getPingId() == this.lastPingId) { long time = System.currentTimeMillis() - this.lastPingTime; session.setFlag(MinecraftConstants.PING_KEY, time); } } else if (packet instanceof ServerboundConfigurationAcknowledgedPacket) { protocol.setState(ProtocolState.CONFIGURATION); - } else if (packet instanceof ServerboundPingRequestPacket) { - session.send(new ClientboundPongResponsePacket(((ServerboundPingRequestPacket) packet).getPingTime())); + } else if (packet instanceof ServerboundPingRequestPacket pingRequestPacket) { + session.send(new ClientboundPongResponsePacket(pingRequestPacket.getPingTime())); } } else if (protocol.getState() == ProtocolState.CONFIGURATION) { if (packet instanceof ServerboundFinishConfigurationPacket) { @@ -178,9 +174,9 @@ public class ServerListener extends SessionAdapter { @Override public void packetSent(Session session, Packet packet) { - if (packet instanceof ClientboundLoginCompressionPacket) { - session.setCompressionThreshold(((ClientboundLoginCompressionPacket) packet).getThreshold(), true); - session.send(new ClientboundGameProfilePacket((GameProfile) session.getFlag(MinecraftConstants.PROFILE_KEY))); + if (packet instanceof ClientboundLoginCompressionPacket loginCompressionPacket) { + session.setCompressionThreshold(loginCompressionPacket.getThreshold(), true); + session.send(new ClientboundGameProfilePacket(session.getFlag(MinecraftConstants.PROFILE_KEY))); } } @@ -194,14 +190,10 @@ public class ServerListener extends SessionAdapter { } } + @RequiredArgsConstructor private class UserAuthTask implements Runnable { - private Session session; - private SecretKey key; - - public UserAuthTask(Session session, SecretKey key) { - this.key = key; - this.session = session; - } + private final Session session; + private final SecretKey key; @Override public void run() { @@ -229,12 +221,9 @@ public class ServerListener extends SessionAdapter { } } + @RequiredArgsConstructor private class KeepAliveTask implements Runnable { - private Session session; - - public KeepAliveTask(Session session) { - this.session = session; - } + private final Session session; @Override public void run() { diff --git a/src/main/java/com/github/steveice10/mc/protocol/ServerLoginHandler.java b/src/main/java/com/github/steveice10/mc/protocol/ServerLoginHandler.java index 03936024..08abd8c8 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/ServerLoginHandler.java +++ b/src/main/java/com/github/steveice10/mc/protocol/ServerLoginHandler.java @@ -12,5 +12,5 @@ public interface ServerLoginHandler { * * @param session Session that logged in. */ - public void loggedIn(Session session); + void loggedIn(Session session); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodecHelper.java b/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodecHelper.java index 23eae663..e4caa67c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodecHelper.java +++ b/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodecHelper.java @@ -70,11 +70,11 @@ import io.netty.buffer.ByteBuf; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.Component; +import org.checkerframework.checker.nullness.qual.NonNull; import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3i; import org.cloudburstmc.math.vector.Vector4f; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; import java.io.InputStream; @@ -193,7 +193,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper { return readAnyTag(buf, CompoundTag.class); } - @NotNull + @NonNull public CompoundTag readAnyTagOrThrow(ByteBuf buf) throws IOException { CompoundTag tag = readAnyTag(buf); if (tag == null) { @@ -221,10 +221,11 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper { return expected.cast(tag); } + public void writeAnyTag(ByteBuf buf, @Nullable T tag) throws IOException { NBTIO.writeAnyTag(new OutputStream() { @Override - public void write(int b) throws IOException { + public void write(int b) { buf.writeByte(b); } }, tag); @@ -241,7 +242,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper { return new ItemStack(item, buf.readByte(), this.readAnyTag(buf)); } - public void writeItemStack(ByteBuf buf, ItemStack item) throws IOException { + public void writeItemStack(ByteBuf buf, @Nullable ItemStack item) throws IOException { buf.writeBoolean(item != null); if (item != null) { this.writeVarInt(buf, item.getId()); @@ -357,7 +358,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper { ret.add(this.readMetadata(buf, id)); } - return ret.toArray(new EntityMetadata[0]); + return ret.toArray(new EntityMetadata[0]); } public void writeEntityMetadata(ByteBuf buf, EntityMetadata[] metadata) throws IOException { @@ -447,105 +448,96 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper { } public ParticleData readParticleData(ByteBuf buf, ParticleType type) throws IOException { - switch (type) { - case BLOCK: - case BLOCK_MARKER: - return new BlockParticleData(this.readVarInt(buf)); - case DUST: + return switch (type) { + case BLOCK, BLOCK_MARKER -> new BlockParticleData(this.readVarInt(buf)); + case DUST -> { + float red = buf.readFloat(); + float green = buf.readFloat(); + float blue = buf.readFloat(); + float scale = buf.readFloat(); + yield new DustParticleData(red, green, blue, scale); + } + case DUST_COLOR_TRANSITION -> { float red = buf.readFloat(); float green = buf.readFloat(); float blue = buf.readFloat(); float scale = buf.readFloat(); - return new DustParticleData(red, green, blue, scale); - case DUST_COLOR_TRANSITION: - red = buf.readFloat(); - green = buf.readFloat(); - blue = buf.readFloat(); - scale = buf.readFloat(); float newRed = buf.readFloat(); float newGreen = buf.readFloat(); float newBlue = buf.readFloat(); - return new DustColorTransitionParticleData(red, green, blue, scale, newRed, newGreen, newBlue); - case FALLING_DUST: - return new FallingDustParticleData(this.readVarInt(buf)); - case ITEM: - return new ItemParticleData(this.readItemStack(buf)); - case SCULK_CHARGE: - return new SculkChargeParticleData(buf.readFloat()); - case SHRIEK: - return new ShriekParticleData(this.readVarInt(buf)); - case VIBRATION: - return new VibrationParticleData(this.readPositionSource(buf), this.readVarInt(buf)); - default: - return null; - } + yield new DustColorTransitionParticleData(red, green, blue, scale, newRed, newGreen, newBlue); + } + case FALLING_DUST -> new FallingDustParticleData(this.readVarInt(buf)); + case ITEM -> new ItemParticleData(this.readItemStack(buf)); + case SCULK_CHARGE -> new SculkChargeParticleData(buf.readFloat()); + case SHRIEK -> new ShriekParticleData(this.readVarInt(buf)); + case VIBRATION -> new VibrationParticleData(this.readPositionSource(buf), this.readVarInt(buf)); + default -> null; + }; } public void writeParticleData(ByteBuf buf, ParticleType type, ParticleData data) throws IOException { switch (type) { - case BLOCK: - case BLOCK_MARKER: - this.writeVarInt(buf, ((BlockParticleData) data).getBlockState()); - break; - case DUST: - buf.writeFloat(((DustParticleData) data).getRed()); - buf.writeFloat(((DustParticleData) data).getGreen()); - buf.writeFloat(((DustParticleData) data).getBlue()); - buf.writeFloat(((DustParticleData) data).getScale()); - break; - case DUST_COLOR_TRANSITION: - buf.writeFloat(((DustParticleData) data).getRed()); - buf.writeFloat(((DustParticleData) data).getGreen()); - buf.writeFloat(((DustParticleData) data).getBlue()); - buf.writeFloat(((DustParticleData) data).getScale()); - buf.writeFloat(((DustColorTransitionParticleData) data).getNewRed()); - buf.writeFloat(((DustColorTransitionParticleData) data).getNewGreen()); - buf.writeFloat(((DustColorTransitionParticleData) data).getNewBlue()); - break; - case FALLING_DUST: - this.writeVarInt(buf, ((FallingDustParticleData) data).getBlockState()); - break; - case ITEM: - this.writeItemStack(buf, ((ItemParticleData) data).getItemStack()); - break; - case SCULK_CHARGE: - buf.writeFloat(((SculkChargeParticleData) data).getRoll()); - break; - case SHRIEK: - this.writeVarInt(buf, ((ShriekParticleData) data).getDelay()); - break; - case VIBRATION: - this.writePositionSource(buf, ((VibrationParticleData) data).getPositionSource()); - this.writeVarInt(buf, ((VibrationParticleData) data).getArrivalTicks()); - break; + case BLOCK, BLOCK_MARKER -> this.writeVarInt(buf, ((BlockParticleData) data).getBlockState()); + case DUST -> { + DustParticleData dust = (DustParticleData) data; + buf.writeFloat(dust.getRed()); + buf.writeFloat(dust.getGreen()); + buf.writeFloat(dust.getBlue()); + buf.writeFloat(dust.getScale()); + } + case DUST_COLOR_TRANSITION -> { + DustColorTransitionParticleData dust = (DustColorTransitionParticleData) data; + buf.writeFloat(dust.getRed()); + buf.writeFloat(dust.getGreen()); + buf.writeFloat(dust.getBlue()); + buf.writeFloat(dust.getScale()); + + buf.writeFloat(dust.getNewRed()); + buf.writeFloat(dust.getNewGreen()); + buf.writeFloat(dust.getNewBlue()); + } + case FALLING_DUST -> { + FallingDustParticleData fallingDust = (FallingDustParticleData) data; + this.writeVarInt(buf, fallingDust.getBlockState()); + } + case ITEM -> { + ItemParticleData item = (ItemParticleData) data; + this.writeItemStack(buf, item.getItemStack()); + } + case SCULK_CHARGE -> { + SculkChargeParticleData sculkCharge = (SculkChargeParticleData) data; + buf.writeFloat(sculkCharge.getRoll()); + } + case SHRIEK -> { + ShriekParticleData shriek = (ShriekParticleData) data; + this.writeVarInt(buf, shriek.getDelay()); + } + case VIBRATION -> { + VibrationParticleData vibration = (VibrationParticleData) data; + this.writePositionSource(buf, vibration.getPositionSource()); + this.writeVarInt(buf, vibration.getArrivalTicks()); + } } } public NumberFormat readNumberFormat(ByteBuf buf) throws IOException { int id = this.readVarInt(buf); - switch (id) { - case 0: - return BlankFormat.INSTANCE; - case 1: - return new StyledFormat(this.readAnyTagOrThrow(buf)); - case 2: - return new FixedFormat(this.readComponent(buf)); - default: - throw new IllegalArgumentException("Unknown number format type: " + id); - } + return switch (id) { + case 0 -> BlankFormat.INSTANCE; + case 1 -> new StyledFormat(this.readAnyTagOrThrow(buf)); + case 2 -> new FixedFormat(this.readComponent(buf)); + default -> throw new IllegalArgumentException("Unknown number format type: " + id); + }; } public void writeNumberFormat(ByteBuf buf, NumberFormat numberFormat) throws IOException { if (numberFormat instanceof BlankFormat) { this.writeVarInt(buf, 0); - } else if (numberFormat instanceof StyledFormat) { - StyledFormat styledFormat = (StyledFormat) numberFormat; - + } else if (numberFormat instanceof StyledFormat styledFormat) { this.writeVarInt(buf, 1); this.writeAnyTag(buf, styledFormat.getStyle()); - } else if (numberFormat instanceof FixedFormat) { - FixedFormat fixedFormat = (FixedFormat) numberFormat; - + } else if (numberFormat instanceof FixedFormat fixedFormat) { this.writeVarInt(buf, 2); this.writeComponent(buf, fixedFormat.getValue()); } else { @@ -555,23 +547,19 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper { public PositionSource readPositionSource(ByteBuf buf) { PositionSourceType type = PositionSourceType.from(this.readVarInt(buf)); - switch (type) { - case BLOCK: - return new BlockPositionSource(this.readPosition(buf)); - case ENTITY: - return new EntityPositionSource(this.readVarInt(buf), buf.readFloat()); - default: - throw new IllegalStateException("Unknown position source type!"); - } + return switch (type) { + case BLOCK -> new BlockPositionSource(this.readPosition(buf)); + case ENTITY -> new EntityPositionSource(this.readVarInt(buf), buf.readFloat()); + }; } public void writePositionSource(ByteBuf buf, PositionSource positionSource) { this.writeVarInt(buf, positionSource.getType().ordinal()); - if (positionSource instanceof BlockPositionSource) { - this.writePosition(buf, ((BlockPositionSource) positionSource).getPosition()); - } else if (positionSource instanceof EntityPositionSource) { - this.writeVarInt(buf, ((EntityPositionSource) positionSource).getEntityId()); - buf.writeFloat(((EntityPositionSource) positionSource).getYOffset()); + if (positionSource instanceof BlockPositionSource blockPositionSource) { + this.writePosition(buf, blockPositionSource.getPosition()); + } else if (positionSource instanceof EntityPositionSource entityPositionSource) { + this.writeVarInt(buf, entityPositionSource.getEntityId()); + buf.writeFloat(entityPositionSource.getYOffset()); } else { throw new IllegalStateException("Unknown position source type!"); } @@ -620,7 +608,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper { } } - @NotNull + @NonNull public BlockEntityType readBlockEntityType(ByteBuf buf) { int id = this.readVarInt(buf); BlockEntityType type = BlockEntityType.from(id); @@ -784,7 +772,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper { this.writeLongArray(buf, data); } - private Palette readPalette(ByteBuf buf, PaletteType paletteType, int bitsPerEntry) throws IOException { + private Palette readPalette(ByteBuf buf, PaletteType paletteType, int bitsPerEntry) { if (bitsPerEntry == 0) { return new SingletonPalette(this.readVarInt(buf)); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/codec/NbtComponentSerializer.java b/src/main/java/com/github/steveice10/mc/protocol/codec/NbtComponentSerializer.java index 9294aa4f..123e75c8 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/codec/NbtComponentSerializer.java +++ b/src/main/java/com/github/steveice10/mc/protocol/codec/NbtComponentSerializer.java @@ -19,8 +19,8 @@ import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.google.gson.internal.LazilyParsedNumber; import lombok.AllArgsConstructor; +import org.checkerframework.checker.nullness.qual.Nullable; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -207,15 +207,13 @@ public class NbtComponentSerializer { convertCompoundTagEntry(entry.getName(), entry, object); } return object; - } else if (tag instanceof ListTag) { - final ListTag list = (ListTag) tag; + } else if (tag instanceof ListTag list) { final JsonArray array = new JsonArray(); for (final Tag listEntry : list) { array.add(convertToJson(null, listEntry)); } return array; - } else if (tag.getValue() instanceof Number) { - final Number number = (Number) tag.getValue(); + } else if (tag.getValue() instanceof Number number) { if (key != null && BOOLEAN_TYPES.contains(key)) { // Booleans don't have a direct representation in nbt return new JsonPrimitive(number.byteValue() != 0); @@ -223,22 +221,19 @@ public class NbtComponentSerializer { return new JsonPrimitive(number); } else if (tag instanceof StringTag) { return new JsonPrimitive(((StringTag) tag).getValue()); - } else if (tag instanceof ByteArrayTag) { - final ByteArrayTag arrayTag = (ByteArrayTag) tag; + } else if (tag instanceof ByteArrayTag arrayTag) { final JsonArray array = new JsonArray(); for (final byte num : arrayTag.getValue()) { array.add(num); } return array; - } else if (tag instanceof IntArrayTag) { - final IntArrayTag arrayTag = (IntArrayTag) tag; + } else if (tag instanceof IntArrayTag arrayTag) { final JsonArray array = new JsonArray(); for (final int num : arrayTag.getValue()) { array.add(num); } return array; - } else if (tag instanceof LongArrayTag) { - final LongArrayTag arrayTag = (LongArrayTag) tag; + } else if (tag instanceof LongArrayTag arrayTag) { final JsonArray array = new JsonArray(); for (final long num : arrayTag.getValue()) { array.add(num); @@ -249,9 +244,8 @@ public class NbtComponentSerializer { } private static void convertCompoundTagEntry(final String key, final Tag tag, final JsonObject object) { - if ((key.equals("contents")) && tag instanceof CompoundTag) { + if ((key.equals("contents")) && tag instanceof CompoundTag showEntity) { // Back to a UUID string - final CompoundTag showEntity = (CompoundTag) tag; final Tag idTag = showEntity.get("id"); if (idTag instanceof IntArrayTag) { showEntity.remove("id"); diff --git a/src/main/java/com/github/steveice10/mc/protocol/codec/PacketStateCodec.java b/src/main/java/com/github/steveice10/mc/protocol/codec/PacketStateCodec.java index 7d01cf56..624b3a8b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/codec/PacketStateCodec.java +++ b/src/main/java/com/github/steveice10/mc/protocol/codec/PacketStateCodec.java @@ -7,6 +7,8 @@ import com.github.steveice10.packetlib.codec.PacketCodecHelper; import com.github.steveice10.packetlib.codec.PacketDefinition; import com.github.steveice10.packetlib.packet.PacketHeader; import com.github.steveice10.packetlib.packet.PacketProtocol; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.util.HashMap; import java.util.Map; @@ -43,8 +45,8 @@ public class PacketStateCodec extends PacketProtocol { } public static class Builder { - private final Map> clientboundPackets = new HashMap<>(); - private final Map> serverboundPackets = new HashMap<>(); + private final Int2ObjectMap> clientboundPackets = new Int2ObjectOpenHashMap<>(); + private final Int2ObjectMap> serverboundPackets = new Int2ObjectOpenHashMap<>(); private int nextClientboundId = 0x00; private int nextServerboundId = 0x00; @@ -73,11 +75,11 @@ public class PacketStateCodec extends PacketProtocol { public PacketStateCodec build() { PacketStateCodec codec = new PacketStateCodec(); - for (Map.Entry> entry : this.clientboundPackets.entrySet()) { + for (Int2ObjectMap.Entry> entry : this.clientboundPackets.int2ObjectEntrySet()) { codec.registerClientbound(entry.getValue()); } - for (Map.Entry> entry : this.serverboundPackets.entrySet()) { + for (Int2ObjectMap.Entry> entry : this.serverboundPackets.int2ObjectEntrySet()) { codec.registerServerbound(entry.getValue()); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java deleted file mode 100644 index e69de29b..00000000 diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/UnexpectedEncryptionException.java b/src/main/java/com/github/steveice10/mc/protocol/data/UnexpectedEncryptionException.java index 03d9faf5..9a190d16 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/UnexpectedEncryptionException.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/UnexpectedEncryptionException.java @@ -1,10 +1,15 @@ package com.github.steveice10.mc.protocol.data; +import java.io.Serial; + /** * Thrown whenever a ClientboundHelloPacket is sent when we aren't expecting it * (I.E.: online mode server and offline mode client) */ public class UnexpectedEncryptionException extends IllegalStateException { + @Serial + private static final long serialVersionUID = 1L; + public UnexpectedEncryptionException() { super("Cannot reply to ClientboundHelloPacket without profile and access token."); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/PlayerListEntry.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/PlayerListEntry.java index 27a97d39..a99ebf60 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/PlayerListEntry.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/PlayerListEntry.java @@ -6,7 +6,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.security.PublicKey; import java.util.UUID; diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java index 20f6cc23..59b6a108 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java @@ -5,7 +5,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.List; diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/chat/MessageSignature.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/chat/MessageSignature.java index b0a0e3ed..a67191c5 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/chat/MessageSignature.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/chat/MessageSignature.java @@ -4,7 +4,7 @@ import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/BitStorage.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/BitStorage.java index ddd1eaf8..0b60468d 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/BitStorage.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/BitStorage.java @@ -1,7 +1,7 @@ package com.github.steveice10.mc.protocol.data.game.chunk; import lombok.*; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Arrays; diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/NibbleArray3d.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/NibbleArray3d.java index 13f8405f..f53a79ab 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/NibbleArray3d.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/NibbleArray3d.java @@ -7,7 +7,7 @@ import lombok.NonNull; @Data @AllArgsConstructor public class NibbleArray3d { - private final @NonNull byte[] data; + private final byte @NonNull [] data; public NibbleArray3d(int size) { this(new byte[size >> 1]); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/ListPalette.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/ListPalette.java index d8781701..73cb2f66 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/ListPalette.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/ListPalette.java @@ -7,7 +7,6 @@ import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import java.io.IOException; import java.util.Arrays; /** @@ -17,18 +16,18 @@ import java.util.Arrays; @EqualsAndHashCode @AllArgsConstructor(access = AccessLevel.PRIVATE) public class ListPalette implements Palette { - private final int maxId; + private final int capacity; private final int[] data; private int nextId = 0; public ListPalette(int bitsPerEntry) { - this.maxId = (1 << bitsPerEntry) - 1; + this.capacity = 1 << bitsPerEntry; - this.data = new int[this.maxId + 1]; + this.data = new int[this.capacity]; } - public ListPalette(int bitsPerEntry, ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ListPalette(int bitsPerEntry, ByteBuf in, MinecraftCodecHelper helper) { this(bitsPerEntry); int paletteLength = helper.readVarInt(in); @@ -53,7 +52,7 @@ public class ListPalette implements Palette { break; } } - if (id == -1 && this.size() < this.maxId + 1) { + if (id == -1 && this.size() < this.capacity) { id = this.nextId++; this.data[id] = state; } @@ -72,6 +71,6 @@ public class ListPalette implements Palette { @Override public ListPalette copy() { - return new ListPalette(this.maxId, Arrays.copyOf(this.data, this.data.length), this.nextId); + return new ListPalette(this.capacity, Arrays.copyOf(this.data, this.data.length), this.nextId); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/MapPalette.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/MapPalette.java index 28faf06d..5936e1a8 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/MapPalette.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/MapPalette.java @@ -2,13 +2,12 @@ package com.github.steveice10.mc.protocol.data.game.chunk.palette; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import io.netty.buffer.ByteBuf; -import io.netty.util.collection.IntObjectHashMap; -import io.netty.util.collection.IntObjectMap; +import it.unimi.dsi.fastutil.ints.Int2IntMap; +import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; -import java.io.IOException; import java.util.Arrays; /** @@ -17,19 +16,21 @@ import java.util.Arrays; @AllArgsConstructor(access = AccessLevel.PRIVATE) @EqualsAndHashCode public class MapPalette implements Palette { - private final int maxId; + private static final int MISSING_ID = -1; + private final int capacity; private final int[] idToState; - private final IntObjectMap stateToId = new IntObjectHashMap<>(); + private final Int2IntMap stateToId = new Int2IntOpenHashMap(); private int nextId = 0; public MapPalette(int bitsPerEntry) { - this.maxId = (1 << bitsPerEntry) - 1; + this.capacity = 1 << bitsPerEntry; - this.idToState = new int[this.maxId + 1]; + this.idToState = new int[this.capacity]; + this.stateToId.defaultReturnValue(MISSING_ID); } - public MapPalette(int bitsPerEntry, ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public MapPalette(int bitsPerEntry, ByteBuf in, MinecraftCodecHelper helper) { this(bitsPerEntry); int paletteLength = helper.readVarInt(in); @@ -48,18 +49,14 @@ public class MapPalette implements Palette { @Override public int stateToId(int state) { - Integer id = this.stateToId.get(state); - if (id == null && this.size() < this.maxId + 1) { + int id = this.stateToId.get(state); + if (id == MISSING_ID && this.size() < this.capacity) { id = this.nextId++; this.idToState[id] = state; this.stateToId.put(state, id); } - if (id != null) { - return id; - } else { - return -1; - } + return id; } @Override @@ -73,7 +70,7 @@ public class MapPalette implements Palette { @Override public MapPalette copy() { - MapPalette mapPalette = new MapPalette(this.maxId, Arrays.copyOf(this.idToState, this.idToState.length), this.nextId); + MapPalette mapPalette = new MapPalette(this.capacity, Arrays.copyOf(this.idToState, this.idToState.length), this.nextId); mapPalette.stateToId.putAll(this.stateToId); return mapPalette; } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/SingletonPalette.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/SingletonPalette.java index 0ded76d8..7a650759 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/SingletonPalette.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/chunk/palette/SingletonPalette.java @@ -1,18 +1,16 @@ package com.github.steveice10.mc.protocol.data.game.chunk.palette; import lombok.EqualsAndHashCode; +import lombok.RequiredArgsConstructor; /** * A palette containing one state. */ @EqualsAndHashCode +@RequiredArgsConstructor public class SingletonPalette implements Palette { private final int state; - public SingletonPalette(int state) { - this.state = state; - } - @Override public int size() { return 1; @@ -20,18 +18,12 @@ public class SingletonPalette implements Palette { @Override public int stateToId(int state) { - if (this.state == state) { - return 0; - } - return -1; + return this.state == state ? 0 : -1; } @Override public int idToState(int id) { - if (id == 0) { - return this.state; - } - return 0; + return id == 0 ? this.state : 0; } @Override diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandNode.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandNode.java index ea1be278..5eeb8de4 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandNode.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandNode.java @@ -23,7 +23,7 @@ public class CommandNode { /** * Child node indices. */ - private final @NonNull int[] childIndices; + private final int @NonNull [] childIndices; /** * Redirect index, or empty if none is set. diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/command/SuggestionType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/command/SuggestionType.java index c35da115..bde7aefe 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/command/SuggestionType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/command/SuggestionType.java @@ -1,7 +1,7 @@ package com.github.steveice10.mc.protocol.data.game.command; import com.github.steveice10.mc.protocol.data.game.Identifier; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.HashMap; import java.util.Locale; @@ -25,7 +25,7 @@ public enum SuggestionType { private static final Map VALUES = new HashMap<>(); - @NotNull + @NonNull public static SuggestionType from(String resourceLocation) { // Vanilla behavior as of 1.19.3 // 1.16.5 still has AVAILABLE_BIOMES and vanilla doesn't care diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/BooleanMetadataType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/BooleanMetadataType.java index 47f40636..f1d37bd8 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/BooleanMetadataType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/BooleanMetadataType.java @@ -4,8 +4,6 @@ import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; import io.netty.buffer.ByteBuf; -import java.io.IOException; - public class BooleanMetadataType extends MetadataType { private final BooleanReader primitiveReader; private final BooleanWriter primitiveWriter; @@ -20,32 +18,32 @@ public class BooleanMetadataType extends MetadataType { } @Override - public EntityMetadata readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) throws IOException { + public EntityMetadata readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) { return this.primitiveFactory.createPrimitive(id, this, this.primitiveReader.readPrimitive(input)); } - public void writeMetadataPrimitive(ByteBuf output, boolean value) throws IOException { + public void writeMetadataPrimitive(ByteBuf output, boolean value) { this.primitiveWriter.writePrimitive(output, value); } @FunctionalInterface public interface BooleanReader extends BasicReader { - boolean readPrimitive(ByteBuf input) throws IOException; + boolean readPrimitive(ByteBuf input); @Deprecated @Override - default Boolean read(ByteBuf input) throws IOException { + default Boolean read(ByteBuf input) { return this.readPrimitive(input); } } @FunctionalInterface public interface BooleanWriter extends BasicWriter { - void writePrimitive(ByteBuf output, boolean value) throws IOException; + void writePrimitive(ByteBuf output, boolean value); @Deprecated @Override - default void write(ByteBuf output, Boolean value) throws IOException { + default void write(ByteBuf output, Boolean value) { this.writePrimitive(output, value); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/ByteMetadataType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/ByteMetadataType.java index 5e4139cd..f64e25a3 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/ByteMetadataType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/ByteMetadataType.java @@ -4,13 +4,11 @@ import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; import io.netty.buffer.ByteBuf; -import java.io.IOException; - public class ByteMetadataType extends MetadataType { private final ByteReader primitiveReader; private final ByteWriter primitiveWriter; private final ByteEntityMetadataFactory primitiveFactory; - + protected ByteMetadataType(ByteReader reader, ByteWriter writer, ByteEntityMetadataFactory metadataFactory) { super(reader, writer, metadataFactory); @@ -20,32 +18,32 @@ public class ByteMetadataType extends MetadataType { } @Override - public EntityMetadata readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) throws IOException { + public EntityMetadata readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) { return this.primitiveFactory.createPrimitive(id, this, this.primitiveReader.readPrimitive(input)); } - public void writeMetadataPrimitive(ByteBuf output, byte value) throws IOException { + public void writeMetadataPrimitive(ByteBuf output, byte value) { this.primitiveWriter.writePrimitive(output, value); } @FunctionalInterface public interface ByteReader extends BasicReader { - byte readPrimitive(ByteBuf input) throws IOException; + byte readPrimitive(ByteBuf input); @Deprecated @Override - default Byte read(ByteBuf input) throws IOException { + default Byte read(ByteBuf input) { return this.readPrimitive(input); } } @FunctionalInterface public interface ByteWriter extends BasicWriter { - void writePrimitive(ByteBuf output, byte value) throws IOException; + void writePrimitive(ByteBuf output, byte value); @Deprecated @Override - default void write(ByteBuf output, Byte value) throws IOException { + default void write(ByteBuf output, Byte value) { this.writePrimitive(output, value); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/EntityMetadata.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/EntityMetadata.java index 7758c5f0..6809d502 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/EntityMetadata.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/EntityMetadata.java @@ -39,10 +39,9 @@ public abstract class EntityMetadata> { if (this == o) { return true; } - if (!(o instanceof EntityMetadata)) { + if (!(o instanceof EntityMetadata that)) { return false; } - EntityMetadata that = (EntityMetadata) o; return this.id == that.id && this.type == that.type && Objects.equals(this.getValue(), that.getValue()); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/Equipment.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/Equipment.java index d454d1d5..bff1fa8e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/Equipment.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/Equipment.java @@ -4,7 +4,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.EquipmentSlot; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/FloatMetadataType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/FloatMetadataType.java index 684ccd06..c8a91423 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/FloatMetadataType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/FloatMetadataType.java @@ -4,8 +4,6 @@ import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.FloatEntityMetadata; import io.netty.buffer.ByteBuf; -import java.io.IOException; - public class FloatMetadataType extends MetadataType { private final FloatReader primitiveReader; private final FloatWriter primitiveWriter; @@ -13,39 +11,39 @@ public class FloatMetadataType extends MetadataType { protected FloatMetadataType(FloatReader reader, FloatWriter writer, FloatEntityMetadataFactory metadataFactory) { super(reader, writer, metadataFactory); - + this.primitiveReader = reader; this.primitiveWriter = writer; this.primitiveFactory = metadataFactory; } @Override - public EntityMetadata readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) throws IOException { + public EntityMetadata readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) { return this.primitiveFactory.createPrimitive(id, this, this.primitiveReader.readPrimitive(input)); } - public void writeMetadataPrimitive(ByteBuf output, float value) throws IOException { + public void writeMetadataPrimitive(ByteBuf output, float value) { this.primitiveWriter.writePrimitive(output, value); } @FunctionalInterface public interface FloatReader extends BasicReader { - float readPrimitive(ByteBuf input) throws IOException; + float readPrimitive(ByteBuf input); @Deprecated @Override - default Float read(ByteBuf input) throws IOException { + default Float read(ByteBuf input) { return this.readPrimitive(input); } } @FunctionalInterface public interface FloatWriter extends BasicWriter { - void writePrimitive(ByteBuf output, float value) throws IOException; + void writePrimitive(ByteBuf output, float value); @Deprecated @Override - default void write(ByteBuf output, Float value) throws IOException { + default void write(ByteBuf output, Float value) { this.writePrimitive(output, value); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/IntMetadataType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/IntMetadataType.java index 7368aa96..f2f5085f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/IntMetadataType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/IntMetadataType.java @@ -4,48 +4,46 @@ import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata; import io.netty.buffer.ByteBuf; -import java.io.IOException; - public class IntMetadataType extends MetadataType { private final IntReader primitiveReader; private final IntWriter primitiveWriter; private final IntEntityMetadataFactory primitiveFactory; - + protected IntMetadataType(IntReader reader, IntWriter writer, IntEntityMetadataFactory metadataFactory) { super(reader, writer, metadataFactory); - + this.primitiveReader = reader; this.primitiveWriter = writer; this.primitiveFactory = metadataFactory; } @Override - public EntityMetadata readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) throws IOException { + public EntityMetadata readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) { return this.primitiveFactory.createPrimitive(id, this, this.primitiveReader.readPrimitive(helper, input)); } - public void writeMetadataPrimitive(MinecraftCodecHelper helper, ByteBuf output, int value) throws IOException { + public void writeMetadataPrimitive(MinecraftCodecHelper helper, ByteBuf output, int value) { this.primitiveWriter.writePrimitive(helper, output, value); } @FunctionalInterface public interface IntReader extends Reader { - int readPrimitive(MinecraftCodecHelper helper, ByteBuf input) throws IOException; + int readPrimitive(MinecraftCodecHelper helper, ByteBuf input); @Deprecated @Override - default Integer read(MinecraftCodecHelper helper, ByteBuf input) throws IOException { + default Integer read(MinecraftCodecHelper helper, ByteBuf input) { return this.readPrimitive(helper, input); } } @FunctionalInterface public interface IntWriter extends Writer { - void writePrimitive(MinecraftCodecHelper helper, ByteBuf output, int value) throws IOException; + void writePrimitive(MinecraftCodecHelper helper, ByteBuf output, int value); @Deprecated @Override - default void write(MinecraftCodecHelper helper, ByteBuf output, Integer value) throws IOException { + default void write(MinecraftCodecHelper helper, ByteBuf output, Integer value) { this.writePrimitive(helper, output, value); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/ItemStack.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/ItemStack.java index 9f111f9a..e1d43153 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/ItemStack.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/ItemStack.java @@ -3,7 +3,7 @@ package com.github.steveice10.mc.protocol.data.game.entity.metadata; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import lombok.AllArgsConstructor; import lombok.Data; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/LongMetadataType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/LongMetadataType.java index 0392865c..f3224853 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/LongMetadataType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/LongMetadataType.java @@ -4,8 +4,6 @@ import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.LongEntityMetadata; import io.netty.buffer.ByteBuf; -import java.io.IOException; - public class LongMetadataType extends MetadataType { private final LongReader primitiveReader; private final LongWriter primitiveWriter; @@ -20,32 +18,32 @@ public class LongMetadataType extends MetadataType { } @Override - public EntityMetadata readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) throws IOException { + public EntityMetadata readMetadata(MinecraftCodecHelper helper, ByteBuf input, int id) { return this.primitiveFactory.createPrimitive(id, this, this.primitiveReader.readPrimitive(helper, input)); } - public void writeMetadataPrimitive(MinecraftCodecHelper helper, ByteBuf output, long value) throws IOException { + public void writeMetadataPrimitive(MinecraftCodecHelper helper, ByteBuf output, long value) { this.primitiveWriter.writePrimitive(helper, output, value); } @FunctionalInterface public interface LongReader extends Reader { - long readPrimitive(MinecraftCodecHelper helper, ByteBuf input) throws IOException; + long readPrimitive(MinecraftCodecHelper helper, ByteBuf input); @Deprecated @Override - default Long read(MinecraftCodecHelper helper, ByteBuf input) throws IOException { + default Long read(MinecraftCodecHelper helper, ByteBuf input) { return this.readPrimitive(helper, input); } } @FunctionalInterface public interface LongWriter extends Writer { - void writePrimitive(MinecraftCodecHelper helper, ByteBuf output, long value) throws IOException; + void writePrimitive(MinecraftCodecHelper helper, ByteBuf output, long value); @Deprecated @Override - default void write(MinecraftCodecHelper helper, ByteBuf output, Long value) throws IOException { + default void write(MinecraftCodecHelper helper, ByteBuf output, Long value) { this.writePrimitive(helper, output, value); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/MetadataType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/MetadataType.java index 3c6960b9..b29b6038 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/MetadataType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/MetadataType.java @@ -150,7 +150,7 @@ public class MetadataType { }; } - public static MetadataType read(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public static MetadataType read(ByteBuf in, MinecraftCodecHelper helper) { int id = helper.readVarInt(in); if (id >= VALUES.size()) { throw new IllegalArgumentException("Received id " + id + " for MetadataType when the maximum was " + VALUES.size() + "!"); @@ -158,11 +158,11 @@ public class MetadataType { return VALUES.get(id); } - + public static MetadataType from(int id) { return VALUES.get(id); } - + public static int size() { return VALUES.size(); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/OptionalIntMetadataType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/OptionalIntMetadataType.java index 75a31ba0..df1efe5d 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/OptionalIntMetadataType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/OptionalIntMetadataType.java @@ -3,7 +3,6 @@ package com.github.steveice10.mc.protocol.data.game.entity.metadata; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import io.netty.buffer.ByteBuf; -import java.io.IOException; import java.util.OptionalInt; public class OptionalIntMetadataType extends MetadataType { @@ -15,7 +14,7 @@ public class OptionalIntMetadataType extends MetadataType { protected static final OptionalIntReader INSTANCE = new OptionalIntReader(); @Override - public OptionalInt read(MinecraftCodecHelper helper, ByteBuf input) throws IOException { + public OptionalInt read(MinecraftCodecHelper helper, ByteBuf input) { int value = helper.readVarInt(input); if (value == 0) { return OptionalInt.empty(); @@ -29,7 +28,7 @@ public class OptionalIntMetadataType extends MetadataType { protected static final OptionalIntWriter INSTANCE = new OptionalIntWriter(); @Override - public void write(MinecraftCodecHelper helper, ByteBuf output, OptionalInt value) throws IOException { + public void write(MinecraftCodecHelper helper, ByteBuf output, OptionalInt value) { if (value.isPresent()) { helper.writeVarInt(output, value.getAsInt() + 1); } else { diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/type/IntEntityMetadata.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/type/IntEntityMetadata.java index d94a0e5e..b1abf18f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/type/IntEntityMetadata.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/type/IntEntityMetadata.java @@ -3,7 +3,6 @@ package com.github.steveice10.mc.protocol.data.game.entity.metadata.type; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.IntMetadataType; -import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType; import io.netty.buffer.ByteBuf; import lombok.NonNull; diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/Animation.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/Animation.java index 13a0979b..f4b63eb1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/Animation.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/Animation.java @@ -2,7 +2,7 @@ package com.github.steveice10.mc.protocol.data.game.entity.player; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; public enum Animation { SWING_ARM(0), diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/GameMode.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/GameMode.java index f195eded..70953b66 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/GameMode.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/GameMode.java @@ -1,7 +1,7 @@ package com.github.steveice10.mc.protocol.data.game.entity.player; import com.github.steveice10.mc.protocol.data.game.level.notify.GameEventValue; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; public enum GameMode implements GameEventValue { SURVIVAL, diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/PlayerSpawnInfo.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/PlayerSpawnInfo.java index 3d301da1..556989e3 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/PlayerSpawnInfo.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/player/PlayerSpawnInfo.java @@ -4,7 +4,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.GlobalPos; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/MoveToHotbarAction.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/MoveToHotbarAction.java index 4a89424c..9bf0600b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/MoveToHotbarAction.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/MoveToHotbarAction.java @@ -25,7 +25,7 @@ public enum MoveToHotbarAction implements ContainerAction { return id; } - private static Int2ObjectMap VALUES = new Int2ObjectOpenHashMap<>(); + private static final Int2ObjectMap VALUES = new Int2ObjectOpenHashMap<>(); public static MoveToHotbarAction from(int id) { return VALUES.get(id); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/SpreadItemAction.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/SpreadItemAction.java index 4f7df5e1..d069b461 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/SpreadItemAction.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/SpreadItemAction.java @@ -24,7 +24,7 @@ public enum SpreadItemAction implements ContainerAction { return id; } - private static Int2ObjectMap VALUES = new Int2ObjectOpenHashMap<>(); + private static final Int2ObjectMap VALUES = new Int2ObjectOpenHashMap<>(); public static SpreadItemAction from(int id) { return VALUES.get(id); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/VillagerTrade.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/VillagerTrade.java index dea65120..64249d88 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/VillagerTrade.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/inventory/VillagerTrade.java @@ -3,7 +3,7 @@ package com.github.steveice10.mc.protocol.data.game.inventory; import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import lombok.AllArgsConstructor; import lombok.Data; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/LightUpdateData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/LightUpdateData.java index 79c6697c..3d7de483 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/LightUpdateData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/LightUpdateData.java @@ -21,11 +21,11 @@ public class LightUpdateData { private final @NonNull List skyUpdates; private final @NonNull List blockUpdates; - public static LightUpdateData read(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public static LightUpdateData read(ByteBuf in, MinecraftCodecHelper helper) { return new LightUpdateData(in, helper); } - private LightUpdateData(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + private LightUpdateData(ByteBuf in, MinecraftCodecHelper helper) { this.skyYMask = BitSet.valueOf(helper.readLongArray(in)); this.blockYMask = BitSet.valueOf(helper.readLongArray(in)); this.emptySkyYMask = BitSet.valueOf(helper.readLongArray(in)); @@ -48,7 +48,7 @@ public class LightUpdateData { data.write(out, helper); } - private void write(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + private void write(ByteBuf out, MinecraftCodecHelper helper) { writeBitSet(out, helper, this.skyYMask); writeBitSet(out, helper, this.blockYMask); writeBitSet(out, helper, this.emptySkyYMask); @@ -65,7 +65,7 @@ public class LightUpdateData { } } - private void writeBitSet(ByteBuf out, MinecraftCodecHelper helper, BitSet bitSet) throws IOException { + private void writeBitSet(ByteBuf out, MinecraftCodecHelper helper, BitSet bitSet) { long[] array = bitSet.toLongArray(); helper.writeLongArray(out, array); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityInfo.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityInfo.java index a05186e4..a791ae6b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityInfo.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityInfo.java @@ -3,7 +3,7 @@ package com.github.steveice10.mc.protocol.data.game.level.block; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import lombok.AllArgsConstructor; import lombok.Data; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityType.java index d2d12fd7..e64c2ba8 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityType.java @@ -1,6 +1,6 @@ package com.github.steveice10.mc.protocol.data.game.level.block; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; public enum BlockEntityType { FURNACE, diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/event/BreakBlockEventData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/event/BreakBlockEventData.java index e46e1969..b54c6c50 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/event/BreakBlockEventData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/event/BreakBlockEventData.java @@ -2,7 +2,6 @@ package com.github.steveice10.mc.protocol.data.game.level.event; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.NonNull; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/map/MapData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/map/MapData.java index 7d3b7665..4a98ff7e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/map/MapData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/map/MapData.java @@ -11,5 +11,5 @@ public class MapData { private final int rows; private final int x; private final int y; - private final @NonNull byte data[]; + private final byte @NonNull [] data; } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/DemoMessageValue.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/DemoMessageValue.java index ebbe2da9..39a4ab95 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/DemoMessageValue.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/DemoMessageValue.java @@ -20,7 +20,7 @@ public enum DemoMessageValue implements GameEventValue { return this.id; } - private static Int2ObjectMap VALUES = new Int2ObjectOpenHashMap<>(); + private static final Int2ObjectMap VALUES = new Int2ObjectOpenHashMap<>(); public static DemoMessageValue from(int id) { return VALUES.get(id); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/particle/ItemParticleData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/particle/ItemParticleData.java index 22e086e0..dfa88534 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/particle/ItemParticleData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/particle/ItemParticleData.java @@ -3,7 +3,7 @@ package com.github.steveice10.mc.protocol.data.game.level.particle; import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import lombok.AllArgsConstructor; import lombok.Data; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/sound/CustomSound.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/sound/CustomSound.java index e5cefe55..c785a07a 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/sound/CustomSound.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/sound/CustomSound.java @@ -2,12 +2,12 @@ package com.github.steveice10.mc.protocol.data.game.level.sound; import lombok.AllArgsConstructor; import lombok.Data; -import org.jetbrains.annotations.NotNull; +import lombok.NonNull; @Data @AllArgsConstructor public class CustomSound implements Sound { - private final @NotNull String name; + private final @NonNull String name; private final boolean newSystem; private final float range; } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/Ingredient.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/Ingredient.java index bf57ccc3..38e48e76 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/Ingredient.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/Ingredient.java @@ -4,7 +4,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/CookedRecipeData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/CookedRecipeData.java index b779010b..a161bf2a 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/CookedRecipeData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/CookedRecipeData.java @@ -6,7 +6,7 @@ import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/ShapedRecipeData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/ShapedRecipeData.java index a53de51a..f0f6742e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/ShapedRecipeData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/ShapedRecipeData.java @@ -6,7 +6,7 @@ import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/ShapelessRecipeData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/ShapelessRecipeData.java index 859ad612..9e2952ba 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/ShapelessRecipeData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/ShapelessRecipeData.java @@ -6,7 +6,7 @@ import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/SmithingTransformRecipeData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/SmithingTransformRecipeData.java index 72193567..d750a8fd 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/SmithingTransformRecipeData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/SmithingTransformRecipeData.java @@ -5,7 +5,7 @@ import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/StoneCuttingRecipeData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/StoneCuttingRecipeData.java index b3e7a80d..11e59ed7 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/StoneCuttingRecipeData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/StoneCuttingRecipeData.java @@ -5,7 +5,7 @@ import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerInfoBuilder.java b/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerInfoBuilder.java index 415fd320..aaaa6167 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerInfoBuilder.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerInfoBuilder.java @@ -4,5 +4,5 @@ import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo; import com.github.steveice10.packetlib.Session; public interface ServerInfoBuilder { - public ServerStatusInfo buildInfo(Session session); + ServerStatusInfo buildInfo(Session session); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerInfoHandler.java b/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerInfoHandler.java index 381246a1..aaccccbb 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerInfoHandler.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerInfoHandler.java @@ -4,5 +4,5 @@ import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo; import com.github.steveice10.packetlib.Session; public interface ServerInfoHandler { - public void handle(Session session, ServerStatusInfo info); + void handle(Session session, ServerStatusInfo info); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerPingTimeHandler.java b/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerPingTimeHandler.java index d87ff6ba..1b5d4464 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerPingTimeHandler.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/status/handler/ServerPingTimeHandler.java @@ -3,5 +3,5 @@ package com.github.steveice10.mc.protocol.data.status.handler; import com.github.steveice10.packetlib.Session; public interface ServerPingTimeHandler { - public void handle(Session session, long pingTime); + void handle(Session session, long pingTime); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundCustomPayloadPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundCustomPayloadPacket.java index 8f950615..56d2959d 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundCustomPayloadPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundCustomPayloadPacket.java @@ -8,8 +8,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,13 +15,13 @@ public class ClientboundCustomPayloadPacket implements MinecraftPacket { private final @NonNull String channel; private final byte @NonNull[] data; - public ClientboundCustomPayloadPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundCustomPayloadPacket(ByteBuf in, MinecraftCodecHelper helper) { this.channel = helper.readString(in); this.data = helper.readByteArray(in, ByteBuf::readableBytes); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeString(out, this.channel); out.writeBytes(this.data); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundKeepAlivePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundKeepAlivePacket.java index 1aac0333..1449cc2d 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundKeepAlivePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundKeepAlivePacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundKeepAlivePacket implements MinecraftPacket { private final long pingId; - public ClientboundKeepAlivePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundKeepAlivePacket(ByteBuf in, MinecraftCodecHelper helper) { this.pingId = in.readLong(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeLong(this.pingId); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundPingPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundPingPacket.java index fba16f5a..020959d9 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundPingPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundPingPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundPingPacket implements MinecraftPacket { private final int id; - public ClientboundPingPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundPingPacket(ByteBuf in, MinecraftCodecHelper helper) { this.id = in.readInt(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeInt(this.id); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundResourcePackPopPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundResourcePackPopPacket.java index 23d2b96f..562bad5f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundResourcePackPopPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundResourcePackPopPacket.java @@ -6,9 +6,8 @@ import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; -import java.io.IOException; import java.util.UUID; @Data @@ -26,7 +25,7 @@ public class ClientboundResourcePackPopPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeNullable(out, this.id, helper::writeUUID); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundResourcePackPushPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundResourcePackPushPacket.java index e3b22fc1..71f54c03 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundResourcePackPushPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundResourcePackPushPacket.java @@ -8,7 +8,7 @@ import lombok.Data; import lombok.NonNull; import lombok.With; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; import java.util.UUID; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundClientInformationPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundClientInformationPacket.java index 3255fd7c..e404f50e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundClientInformationPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundClientInformationPacket.java @@ -11,7 +11,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -31,7 +30,7 @@ public class ServerboundClientInformationPacket implements MinecraftPacket { */ private final boolean allowsListing; - public ServerboundClientInformationPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundClientInformationPacket(ByteBuf in, MinecraftCodecHelper helper) { this.locale = helper.readString(in); this.renderDistance = in.readByte(); this.chatVisibility = ChatVisibility.from(helper.readVarInt(in)); @@ -52,7 +51,7 @@ public class ServerboundClientInformationPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeString(out, this.locale); out.writeByte(this.renderDistance); helper.writeVarInt(out, this.chatVisibility.ordinal()); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundCustomPayloadPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundCustomPayloadPacket.java index 623bc844..9a3ad5e0 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundCustomPayloadPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundCustomPayloadPacket.java @@ -8,8 +8,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,13 +15,13 @@ public class ServerboundCustomPayloadPacket implements MinecraftPacket { private final @NonNull String channel; private final byte @NonNull[] data; - public ServerboundCustomPayloadPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundCustomPayloadPacket(ByteBuf in, MinecraftCodecHelper helper) { this.channel = helper.readString(in); this.data = helper.readByteArray(in, ByteBuf::readableBytes); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeString(out, this.channel); out.writeBytes(this.data); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundKeepAlivePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundKeepAlivePacket.java index a73dd6e5..65c53dc5 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundKeepAlivePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundKeepAlivePacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundKeepAlivePacket implements MinecraftPacket { private final long pingId; - public ServerboundKeepAlivePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundKeepAlivePacket(ByteBuf in, MinecraftCodecHelper helper) { this.pingId = in.readLong(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeLong(this.pingId); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundPongPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundPongPacket.java index e81923e4..7356a12c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundPongPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundPongPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundPongPacket implements MinecraftPacket { private final int id; - public ServerboundPongPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundPongPacket(ByteBuf in, MinecraftCodecHelper helper) { this.id = in.readInt(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeInt(this.id); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundResourcePackPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundResourcePackPacket.java index c94cf1ca..1c3ff144 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundResourcePackPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundResourcePackPacket.java @@ -9,7 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; import java.util.UUID; @Data @@ -20,13 +19,13 @@ public class ServerboundResourcePackPacket implements MinecraftPacket { private final @NonNull UUID id; private final @NonNull ResourcePackStatus status; - public ServerboundResourcePackPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundResourcePackPacket(ByteBuf in, MinecraftCodecHelper helper) { this.id = helper.readUUID(in); this.status = ResourcePackStatus.from(helper.readVarInt(in)); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeUUID(out, id); helper.writeVarInt(out, this.status.ordinal()); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundUpdateEnabledFeaturesPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundUpdateEnabledFeaturesPacket.java index 6b22e834..fe4cd9f8 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundUpdateEnabledFeaturesPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundUpdateEnabledFeaturesPacket.java @@ -7,22 +7,20 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundUpdateEnabledFeaturesPacket implements MinecraftPacket { private final String[] features; - public ClientboundUpdateEnabledFeaturesPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundUpdateEnabledFeaturesPacket(ByteBuf in, MinecraftCodecHelper helper) { this.features = new String[helper.readVarInt(in)]; for (int i = 0; i < this.features.length; i++) { this.features[i] = helper.readString(in); } } - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.features.length); for (String feature : this.features) { helper.writeString(out, feature); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/handshake/serverbound/ClientIntentionPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/handshake/serverbound/ClientIntentionPacket.java index 056cfd4b..14f0ff0f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/handshake/serverbound/ClientIntentionPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/handshake/serverbound/ClientIntentionPacket.java @@ -9,8 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -20,7 +18,7 @@ public class ClientIntentionPacket implements MinecraftPacket { private final int port; private final @NonNull HandshakeIntent intent; - public ClientIntentionPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientIntentionPacket(ByteBuf in, MinecraftCodecHelper helper) { this.protocolVersion = helper.readVarInt(in); this.hostname = helper.readString(in); this.port = in.readUnsignedShort(); @@ -28,7 +26,7 @@ public class ClientIntentionPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.protocolVersion); helper.writeString(out, this.hostname); out.writeShort(this.port); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundAwardStatsPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundAwardStatsPacket.java index 66bddc53..6c6b9980 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundAwardStatsPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundAwardStatsPacket.java @@ -12,10 +12,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - @Data @With @AllArgsConstructor @@ -27,44 +23,23 @@ public class ClientboundAwardStatsPacket implements MinecraftPacket { for (int index = 0; index < length; index++) { StatisticCategory category = helper.readStatisticCategory(in); int statisticId = helper.readVarInt(in); - Statistic statistic; - switch (category) { - case BREAK_BLOCK: - statistic = new BreakBlockStatistic(statisticId); - break; - case CRAFT_ITEM: - statistic = new CraftItemStatistic(statisticId); - break; - case USE_ITEM: - statistic = new UseItemStatistic(statisticId); - break; - case BREAK_ITEM: - statistic = new BreakItemStatistic(statisticId); - break; - case PICKED_UP_ITEM: - statistic = new PickupItemStatistic(statisticId); - break; - case DROP_ITEM: - statistic = new DropItemStatistic(statisticId); - break; - case KILL_ENTITY: - statistic = new KillEntityStatistic(EntityType.from(statisticId)); - break; - case KILLED_BY_ENTITY: - statistic = new KilledByEntityStatistic(EntityType.from(statisticId)); - break; - case CUSTOM: - statistic = CustomStatistic.from(statisticId); - break; - default: - throw new IllegalStateException(); - } + Statistic statistic = switch (category) { + case BREAK_BLOCK -> new BreakBlockStatistic(statisticId); + case CRAFT_ITEM -> new CraftItemStatistic(statisticId); + case USE_ITEM -> new UseItemStatistic(statisticId); + case BREAK_ITEM -> new BreakItemStatistic(statisticId); + case PICKED_UP_ITEM -> new PickupItemStatistic(statisticId); + case DROP_ITEM -> new DropItemStatistic(statisticId); + case KILL_ENTITY -> new KillEntityStatistic(EntityType.from(statisticId)); + case KILLED_BY_ENTITY -> new KilledByEntityStatistic(EntityType.from(statisticId)); + case CUSTOM -> CustomStatistic.from(statisticId); + }; this.statistics.put(statistic, helper.readVarInt(in)); } } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.statistics.size()); for (Object2IntMap.Entry entry : statistics.object2IntEntrySet()) { Statistic statistic = entry.getKey(); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundBossEventPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundBossEventPacket.java index e182db56..3ac0368c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundBossEventPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundBossEventPacket.java @@ -2,7 +2,6 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.codec.MinecraftPacket; -import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; import com.github.steveice10.mc.protocol.data.game.BossBarAction; import com.github.steveice10.mc.protocol.data.game.BossBarColor; import com.github.steveice10.mc.protocol.data.game.BossBarDivision; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundBundlePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundBundlePacket.java index 7389b000..e857c810 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundBundlePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundBundlePacket.java @@ -6,7 +6,6 @@ import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; -import java.io.IOException; import java.util.List; @Data @@ -15,6 +14,6 @@ public class ClientboundBundlePacket implements MinecraftPacket { private final List packets; @Override - public void serialize(ByteBuf buf, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf buf, MinecraftCodecHelper helper) { } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChangeDifficultyPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChangeDifficultyPacket.java index d2f05742..e26d51bc 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChangeDifficultyPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChangeDifficultyPacket.java @@ -9,8 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,13 +16,13 @@ public class ClientboundChangeDifficultyPacket implements MinecraftPacket { private final @NonNull Difficulty difficulty; private final boolean difficultyLocked; - public ClientboundChangeDifficultyPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundChangeDifficultyPacket(ByteBuf in, MinecraftCodecHelper helper) { this.difficulty = Difficulty.from(in.readUnsignedByte()); this.difficultyLocked = in.readBoolean(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeByte(this.difficulty.ordinal()); out.writeBoolean(this.difficultyLocked); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandSuggestionsPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandSuggestionsPacket.java index 12337c53..3930f45d 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandSuggestionsPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandSuggestionsPacket.java @@ -2,7 +2,6 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.codec.MinecraftPacket; -import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; import io.netty.buffer.ByteBuf; import lombok.Data; import lombok.NonNull; @@ -18,10 +17,10 @@ public class ClientboundCommandSuggestionsPacket implements MinecraftPacket { private final int transactionId; private final int start; private final int length; - private final @NonNull String[] matches; - private final @NonNull Component[] tooltips; + private final @NonNull String @NonNull [] matches; + private final Component @NonNull [] tooltips; - public ClientboundCommandSuggestionsPacket(int transactionId, int start, int length, @NonNull String[] matches, @NonNull Component[] tooltips) { + public ClientboundCommandSuggestionsPacket(int transactionId, int start, int length, @NonNull String @NonNull [] matches, Component @NonNull [] tooltips) { if (tooltips.length != matches.length) { throw new IllegalArgumentException("Length of matches and tooltips must be equal."); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java index 98758ee8..7b829956 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java @@ -62,7 +62,7 @@ public class ClientboundCommandsPacket implements MinecraftPacket { if (type == CommandType.ARGUMENT) { parser = CommandParser.from(helper.readVarInt(in)); switch (parser) { - case DOUBLE: { + case DOUBLE -> { byte numberFlags = in.readByte(); double min = -Double.MAX_VALUE; double max = Double.MAX_VALUE; @@ -75,9 +75,8 @@ public class ClientboundCommandsPacket implements MinecraftPacket { } properties = new DoubleProperties(min, max); - break; } - case FLOAT: { + case FLOAT -> { byte numberFlags = in.readByte(); float min = -Float.MAX_VALUE; float max = Float.MAX_VALUE; @@ -90,9 +89,8 @@ public class ClientboundCommandsPacket implements MinecraftPacket { } properties = new FloatProperties(min, max); - break; } - case INTEGER: { + case INTEGER -> { byte numberFlags = in.readByte(); int min = Integer.MIN_VALUE; int max = Integer.MAX_VALUE; @@ -105,9 +103,8 @@ public class ClientboundCommandsPacket implements MinecraftPacket { } properties = new IntegerProperties(min, max); - break; } - case LONG: { + case LONG -> { byte numberFlags = in.readByte(); long min = Long.MIN_VALUE; long max = Long.MAX_VALUE; @@ -120,31 +117,19 @@ public class ClientboundCommandsPacket implements MinecraftPacket { } properties = new LongProperties(min, max); - break; } - case STRING: - properties = StringProperties.from(helper.readVarInt(in)); - break; - case ENTITY: { + case STRING -> properties = StringProperties.from(helper.readVarInt(in)); + case ENTITY -> { byte entityFlags = in.readByte(); properties = new EntityProperties((entityFlags & ENTITY_FLAG_SINGLE_TARGET) != 0, (entityFlags & ENTITY_FLAG_PLAYERS_ONLY) != 0); - break; } - case SCORE_HOLDER: - properties = new ScoreHolderProperties(in.readBoolean()); - break; - case TIME: - properties = new TimeProperties(in.readInt()); - break; - case RESOURCE_OR_TAG: - case RESOURCE_OR_TAG_KEY: - case RESOURCE: - case RESOURCE_KEY: - properties = new ResourceProperties(helper.readString(in)); - break; - default: - break; + case SCORE_HOLDER -> properties = new ScoreHolderProperties(in.readBoolean()); + case TIME -> properties = new TimeProperties(in.readInt()); + case RESOURCE_OR_TAG, RESOURCE_OR_TAG_KEY, RESOURCE, RESOURCE_KEY -> + properties = new ResourceProperties(helper.readString(in)); + default -> { + } } if ((flags & FLAG_SUGGESTION_TYPE) != 0) { @@ -193,7 +178,7 @@ public class ClientboundCommandsPacket implements MinecraftPacket { if (node.getType() == CommandType.ARGUMENT) { helper.writeVarInt(out, node.getParser().ordinal()); switch (node.getParser()) { - case DOUBLE: { + case DOUBLE -> { DoubleProperties properties = (DoubleProperties) node.getProperties(); int numberFlags = 0; @@ -213,10 +198,8 @@ public class ClientboundCommandsPacket implements MinecraftPacket { if ((numberFlags & NUMBER_FLAG_MAX_DEFINED) != 0) { out.writeDouble(properties.getMax()); } - - break; } - case FLOAT: { + case FLOAT -> { FloatProperties properties = (FloatProperties) node.getProperties(); int numberFlags = 0; @@ -236,10 +219,8 @@ public class ClientboundCommandsPacket implements MinecraftPacket { if ((numberFlags & NUMBER_FLAG_MAX_DEFINED) != 0) { out.writeFloat(properties.getMax()); } - - break; } - case INTEGER: { + case INTEGER -> { IntegerProperties properties = (IntegerProperties) node.getProperties(); int numberFlags = 0; @@ -259,10 +240,8 @@ public class ClientboundCommandsPacket implements MinecraftPacket { if ((numberFlags & NUMBER_FLAG_MAX_DEFINED) != 0) { out.writeInt(properties.getMax()); } - - break; } - case LONG: { + case LONG -> { LongProperties properties = (LongProperties) node.getProperties(); int numberFlags = 0; @@ -282,13 +261,9 @@ public class ClientboundCommandsPacket implements MinecraftPacket { if ((numberFlags & NUMBER_FLAG_MAX_DEFINED) != 0) { out.writeLong(properties.getMax()); } - - break; } - case STRING: - helper.writeVarInt(out, ((StringProperties) node.getProperties()).ordinal()); - break; - case ENTITY: { + case STRING -> helper.writeVarInt(out, ((StringProperties) node.getProperties()).ordinal()); + case ENTITY -> { EntityProperties properties = (EntityProperties) node.getProperties(); int entityFlags = 0; if (properties.isSingleTarget()) { @@ -300,22 +275,14 @@ public class ClientboundCommandsPacket implements MinecraftPacket { } out.writeByte(entityFlags); - break; } - case SCORE_HOLDER: - out.writeBoolean(((ScoreHolderProperties) node.getProperties()).isAllowMultiple()); - break; - case TIME: - out.writeInt(((TimeProperties) node.getProperties()).getMin()); - break; - case RESOURCE_OR_TAG: - case RESOURCE_OR_TAG_KEY: - case RESOURCE: - case RESOURCE_KEY: - helper.writeString(out, ((ResourceProperties) node.getProperties()).getRegistryKey()); - break; - default: - break; + case SCORE_HOLDER -> + out.writeBoolean(((ScoreHolderProperties) node.getProperties()).isAllowMultiple()); + case TIME -> out.writeInt(((TimeProperties) node.getProperties()).getMin()); + case RESOURCE_OR_TAG, RESOURCE_OR_TAG_KEY, RESOURCE, RESOURCE_KEY -> + helper.writeString(out, ((ResourceProperties) node.getProperties()).getRegistryKey()); + default -> { + } } if (node.getSuggestionType() != null) { diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCooldownPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCooldownPacket.java index 1f0e61a0..5e60a64b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCooldownPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCooldownPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -16,13 +14,13 @@ public class ClientboundCooldownPacket implements MinecraftPacket { private final int itemId; private final int cooldownTicks; - public ClientboundCooldownPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundCooldownPacket(ByteBuf in, MinecraftCodecHelper helper) { this.itemId = helper.readVarInt(in); this.cooldownTicks = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.itemId); helper.writeVarInt(out, this.cooldownTicks); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundDeleteChatPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundDeleteChatPacket.java index 65ec997c..be59626c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundDeleteChatPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundDeleteChatPacket.java @@ -8,8 +8,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundDisguisedChatPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundDisguisedChatPacket.java index 0ed4cf32..714216ef 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundDisguisedChatPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundDisguisedChatPacket.java @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundLoginPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundLoginPacket.java index e3d05bc8..282789b5 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundLoginPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundLoginPacket.java @@ -2,18 +2,12 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.codec.MinecraftPacket; -import com.github.steveice10.mc.protocol.data.game.entity.metadata.GlobalPos; -import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerSpawnInfo; -import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; import lombok.With; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; @Data @With @@ -30,7 +24,7 @@ public class ClientboundLoginPacket implements MinecraftPacket { private final boolean doLimitedCrafting; private final PlayerSpawnInfo commonPlayerSpawnInfo; - public ClientboundLoginPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundLoginPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = in.readInt(); this.hardcore = in.readBoolean(); int worldCount = helper.readVarInt(in); @@ -48,7 +42,7 @@ public class ClientboundLoginPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeInt(this.entityId); out.writeBoolean(this.hardcore); helper.writeVarInt(out, this.worldNames.length); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerChatPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerChatPacket.java index 2e46f55d..9eb757fa 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerChatPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerChatPacket.java @@ -10,7 +10,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; import java.util.ArrayList; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoRemovePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoRemovePacket.java index 785f8680..776f7eba 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoRemovePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoRemovePacket.java @@ -7,7 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -18,7 +17,7 @@ import java.util.UUID; public class ClientboundPlayerInfoRemovePacket implements MinecraftPacket { private final List profileIds; - public ClientboundPlayerInfoRemovePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundPlayerInfoRemovePacket(ByteBuf in, MinecraftCodecHelper helper) { this.profileIds = new ArrayList<>(); int numIds = helper.readVarInt(in); for (int i = 0; i < numIds; i++) { @@ -26,7 +25,7 @@ public class ClientboundPlayerInfoRemovePacket implements MinecraftPacket { } } - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.profileIds.size()); for (UUID id : this.profileIds) { helper.writeUUID(out, id); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java index 065623f4..c2340050 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java @@ -20,7 +20,6 @@ import java.security.spec.X509EncodedKeySpec; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; -import java.util.UUID; @Data @With @@ -36,7 +35,7 @@ public class ClientboundPlayerInfoUpdatePacket implements MinecraftPacket { PlayerListEntry entry = new PlayerListEntry(helper.readUUID(in)); for (PlayerListEntryAction action : this.actions) { switch (action) { - case ADD_PLAYER: { + case ADD_PLAYER -> { GameProfile profile = new GameProfile(entry.getProfileId(), helper.readString(in, 16)); int propertyCount = helper.readVarInt(in); List propertyList = new ArrayList<>(); @@ -47,9 +46,8 @@ public class ClientboundPlayerInfoUpdatePacket implements MinecraftPacket { profile.setProperties(propertyList); entry.setProfile(profile); - break; } - case INITIALIZE_CHAT: { + case INITIALIZE_CHAT -> { if (in.readBoolean()) { entry.setSessionId(helper.readUUID(in)); entry.setExpiresAt(in.readLong()); @@ -65,31 +63,26 @@ public class ClientboundPlayerInfoUpdatePacket implements MinecraftPacket { entry.setPublicKey(publicKey); } - break; } - case UPDATE_GAME_MODE: { + case UPDATE_GAME_MODE -> { GameMode gameMode = GameMode.byId(helper.readVarInt(in)); entry.setGameMode(gameMode); - break; } - case UPDATE_LISTED: { + case UPDATE_LISTED -> { boolean listed = in.readBoolean(); entry.setListed(listed); - break; } - case UPDATE_LATENCY: { + case UPDATE_LATENCY -> { int latency = helper.readVarInt(in); entry.setLatency(latency); - break; } - case UPDATE_DISPLAY_NAME: { + case UPDATE_DISPLAY_NAME -> { Component displayName = helper.readNullable(in, helper::readComponent); entry.setDisplayName(displayName); - break; } } } @@ -105,14 +98,14 @@ public class ClientboundPlayerInfoUpdatePacket implements MinecraftPacket { helper.writeUUID(out, entry.getProfile().getId()); for (PlayerListEntryAction action : this.actions) { switch (action) { - case ADD_PLAYER: + case ADD_PLAYER -> { helper.writeString(out, entry.getProfile().getName()); helper.writeVarInt(out, entry.getProfile().getProperties().size()); for (GameProfile.Property property : entry.getProfile().getProperties()) { helper.writeProperty(out, property); } - break; - case INITIALIZE_CHAT: + } + case INITIALIZE_CHAT -> { out.writeBoolean(entry.getPublicKey() != null); if (entry.getPublicKey() != null) { helper.writeUUID(out, entry.getSessionId()); @@ -120,19 +113,12 @@ public class ClientboundPlayerInfoUpdatePacket implements MinecraftPacket { helper.writeByteArray(out, entry.getPublicKey().getEncoded()); helper.writeByteArray(out, entry.getKeySignature()); } - break; - case UPDATE_GAME_MODE: - helper.writeVarInt(out, entry.getGameMode().ordinal()); - break; - case UPDATE_LISTED: - out.writeBoolean(entry.isListed()); - break; - case UPDATE_LATENCY: - helper.writeVarInt(out, entry.getLatency()); - break; - case UPDATE_DISPLAY_NAME: - helper.writeNullable(out, entry.getDisplayName(), helper::writeComponent); - break; + } + case UPDATE_GAME_MODE -> helper.writeVarInt(out, entry.getGameMode().ordinal()); + case UPDATE_LISTED -> out.writeBoolean(entry.isListed()); + case UPDATE_LATENCY -> helper.writeVarInt(out, entry.getLatency()); + case UPDATE_DISPLAY_NAME -> + helper.writeNullable(out, entry.getDisplayName(), helper::writeComponent); } } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRecipePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRecipePacket.java index c35acf44..9ebabc78 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRecipePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRecipePacket.java @@ -6,7 +6,6 @@ import com.github.steveice10.mc.protocol.data.game.UnlockRecipesAction; import io.netty.buffer.ByteBuf; import lombok.*; -import java.io.IOException; import java.util.Arrays; @Data @@ -71,7 +70,7 @@ public class ClientboundRecipePacket implements MinecraftPacket { this.alreadyKnownRecipes = Arrays.copyOf(alreadyKnownRecipes, alreadyKnownRecipes.length); } - public ClientboundRecipePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundRecipePacket(ByteBuf in, MinecraftCodecHelper helper) { this.action = UnlockRecipesAction.from(helper.readVarInt(in)); this.openCraftingBook = in.readBoolean(); @@ -99,7 +98,7 @@ public class ClientboundRecipePacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.action.ordinal()); out.writeBoolean(this.openCraftingBook); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRespawnPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRespawnPacket.java index 7278b9db..2c64e4f8 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRespawnPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRespawnPacket.java @@ -2,15 +2,11 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.codec.MinecraftPacket; -import com.github.steveice10.mc.protocol.data.game.entity.metadata.GlobalPos; -import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerSpawnInfo; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.NonNull; import lombok.With; -import org.jetbrains.annotations.Nullable; @Data @With diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSelectAdvancementsTabPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSelectAdvancementsTabPacket.java index 0a65cd68..3f129828 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSelectAdvancementsTabPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSelectAdvancementsTabPacket.java @@ -7,15 +7,13 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundSelectAdvancementsTabPacket implements MinecraftPacket { private final String tabId; - public ClientboundSelectAdvancementsTabPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSelectAdvancementsTabPacket(ByteBuf in, MinecraftCodecHelper helper) { if (in.readBoolean()) { this.tabId = helper.readString(in); } else { @@ -24,7 +22,7 @@ public class ClientboundSelectAdvancementsTabPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { if (this.tabId != null) { out.writeBoolean(true); helper.writeString(out, this.tabId); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundServerDataPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundServerDataPacket.java index dfa47f75..0bd560b1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundServerDataPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundServerDataPacket.java @@ -7,7 +7,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSetCameraPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSetCameraPacket.java index 9c88a751..e820b953 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSetCameraPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSetCameraPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundSetCameraPacket implements MinecraftPacket { private final int cameraEntityId; - public ClientboundSetCameraPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetCameraPacket(ByteBuf in, MinecraftCodecHelper helper) { this.cameraEntityId = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.cameraEntityId); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSoundEntityPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSoundEntityPacket.java index eca9d199..67708eb0 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSoundEntityPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSoundEntityPacket.java @@ -12,8 +12,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -35,7 +33,7 @@ public class ClientboundSoundEntityPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { if (this.sound instanceof CustomSound) { helper.writeVarInt(out, 0); helper.writeSoundEvent(out, this.sound); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundStartConfigurationPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundStartConfigurationPacket.java index 81b251a5..8152b999 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundStartConfigurationPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundStartConfigurationPacket.java @@ -6,8 +6,6 @@ import io.netty.buffer.ByteBuf; import lombok.Data; import lombok.NoArgsConstructor; -import java.io.IOException; - @Data @NoArgsConstructor public class ClientboundStartConfigurationPacket implements MinecraftPacket { @@ -15,6 +13,6 @@ public class ClientboundStartConfigurationPacket implements MinecraftPacket { public ClientboundStartConfigurationPacket(ByteBuf in, MinecraftCodecHelper helper) { } - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundStopSoundPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundStopSoundPacket.java index 2a0b9120..00a2a20b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundStopSoundPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundStopSoundPacket.java @@ -2,17 +2,12 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.codec.MinecraftPacket; -import com.github.steveice10.mc.protocol.data.game.level.sound.BuiltinSound; -import com.github.steveice10.mc.protocol.data.game.level.sound.CustomSound; -import com.github.steveice10.mc.protocol.data.game.level.sound.Sound; import com.github.steveice10.mc.protocol.data.game.level.sound.SoundCategory; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @With @@ -24,7 +19,7 @@ public class ClientboundStopSoundPacket implements MinecraftPacket { private final @Nullable SoundCategory category; private final @Nullable String sound; - public ClientboundStopSoundPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundStopSoundPacket(ByteBuf in, MinecraftCodecHelper helper) { int flags = in.readByte(); if ((flags & FLAG_CATEGORY) != 0) { this.category = helper.readSoundCategory(in); @@ -40,7 +35,7 @@ public class ClientboundStopSoundPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { int flags = 0; if (this.category != null) { flags |= FLAG_CATEGORY; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundTickingStatePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundTickingStatePacket.java index a4766a2d..f6c985af 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundTickingStatePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundTickingStatePacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -23,7 +21,7 @@ public class ClientboundTickingStatePacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeFloat(tickRate); out.writeBoolean(isFrozen); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundTickingStepPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundTickingStepPacket.java index 10713a0b..c0840e97 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundTickingStepPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundTickingStepPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -21,7 +19,7 @@ public class ClientboundTickingStepPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.tickSteps); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundUpdateRecipesPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundUpdateRecipesPacket.java index 82c251cd..b8746395 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundUpdateRecipesPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundUpdateRecipesPacket.java @@ -29,7 +29,7 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket { String identifier = helper.readResourceLocation(in); RecipeData data; switch (type) { - case CRAFTING_SHAPELESS: { + case CRAFTING_SHAPELESS -> { String group = helper.readString(in); CraftingBookCategory category = CraftingBookCategory.from(helper.readVarInt(in)); Ingredient[] ingredients = new Ingredient[helper.readVarInt(in)]; @@ -40,9 +40,8 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket { ItemStack result = helper.readItemStack(in); data = new ShapelessRecipeData(group, category, ingredients, result); - break; } - case CRAFTING_SHAPED: { + case CRAFTING_SHAPED -> { String group = helper.readString(in); CraftingBookCategory category = CraftingBookCategory.from(helper.readVarInt(in)); @@ -58,12 +57,8 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket { boolean showNotification = in.readBoolean(); data = new ShapedRecipeData(width, height, group, category, ingredients, result, showNotification); - break; } - case SMELTING: - case BLASTING: - case SMOKING: - case CAMPFIRE_COOKING: { + case SMELTING, BLASTING, SMOKING, CAMPFIRE_COOKING -> { String group = helper.readString(in); CraftingBookCategory category = CraftingBookCategory.from(helper.readVarInt(in)); Ingredient ingredient = helper.readRecipeIngredient(in); @@ -72,38 +67,33 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket { int cookingTime = helper.readVarInt(in); data = new CookedRecipeData(group, category, ingredient, result, experience, cookingTime); - break; } - case STONECUTTING: { + case STONECUTTING -> { String group = helper.readString(in); Ingredient ingredient = helper.readRecipeIngredient(in); ItemStack result = helper.readItemStack(in); data = new StoneCuttingRecipeData(group, ingredient, result); - break; } - case SMITHING_TRANSFORM: { + case SMITHING_TRANSFORM -> { Ingredient template = helper.readRecipeIngredient(in); Ingredient base = helper.readRecipeIngredient(in); Ingredient addition = helper.readRecipeIngredient(in); ItemStack result = helper.readItemStack(in); data = new SmithingTransformRecipeData(template, base, addition, result); - break; } - case SMITHING_TRIM: { + case SMITHING_TRIM -> { Ingredient template = helper.readRecipeIngredient(in); Ingredient base = helper.readRecipeIngredient(in); Ingredient addition = helper.readRecipeIngredient(in); data = new SmithingTrimRecipeData(template, base, addition); - break; } - default: { + default -> { CraftingBookCategory category = CraftingBookCategory.from(helper.readVarInt(in)); data = new SimpleCraftingRecipeData(category); - break; } } @@ -118,7 +108,7 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket { helper.writeResourceLocation(out, recipe.getType().getResourceLocation()); helper.writeResourceLocation(out, recipe.getIdentifier()); switch (recipe.getType()) { - case CRAFTING_SHAPELESS: { + case CRAFTING_SHAPELESS -> { ShapelessRecipeData data = (ShapelessRecipeData) recipe.getData(); helper.writeString(out, data.getGroup()); @@ -129,9 +119,8 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket { } helper.writeItemStack(out, data.getResult()); - break; } - case CRAFTING_SHAPED: { + case CRAFTING_SHAPED -> { ShapedRecipeData data = (ShapedRecipeData) recipe.getData(); if (data.getIngredients().length != data.getWidth() * data.getHeight()) { throw new IllegalStateException("Shaped recipe must have ingredient count equal to width * height."); @@ -149,12 +138,8 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket { helper.writeItemStack(out, data.getResult()); out.writeBoolean(data.isShowNotification()); - break; } - case SMELTING: - case BLASTING: - case SMOKING: - case CAMPFIRE_COOKING: { + case SMELTING, BLASTING, SMOKING, CAMPFIRE_COOKING -> { CookedRecipeData data = (CookedRecipeData) recipe.getData(); helper.writeString(out, data.getGroup()); @@ -163,38 +148,33 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket { helper.writeItemStack(out, data.getResult()); out.writeFloat(data.getExperience()); helper.writeVarInt(out, data.getCookingTime()); - break; } - case STONECUTTING: { + case STONECUTTING -> { StoneCuttingRecipeData data = (StoneCuttingRecipeData) recipe.getData(); helper.writeString(out, data.getGroup()); helper.writeRecipeIngredient(out, data.getIngredient()); helper.writeItemStack(out, data.getResult()); - break; } - case SMITHING_TRANSFORM: { + case SMITHING_TRANSFORM -> { SmithingTransformRecipeData data = (SmithingTransformRecipeData) recipe.getData(); helper.writeRecipeIngredient(out, data.getTemplate()); helper.writeRecipeIngredient(out, data.getBase()); helper.writeRecipeIngredient(out, data.getAddition()); helper.writeItemStack(out, data.getResult()); - break; } - case SMITHING_TRIM: { + case SMITHING_TRIM -> { SmithingTrimRecipeData data = (SmithingTrimRecipeData) recipe.getData(); helper.writeRecipeIngredient(out, data.getTemplate()); helper.writeRecipeIngredient(out, data.getBase()); helper.writeRecipeIngredient(out, data.getAddition()); - break; } - default: { + default -> { SimpleCraftingRecipeData data = (SimpleCraftingRecipeData) recipe.getData(); helper.writeVarInt(out, data.getCategory().ordinal()); - break; } } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundAnimatePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundAnimatePacket.java index fbeef1f2..f26461d2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundAnimatePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundAnimatePacket.java @@ -7,9 +7,7 @@ import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @With @@ -18,13 +16,13 @@ public class ClientboundAnimatePacket implements MinecraftPacket { private final int entityId; private final @Nullable Animation animation; - public ClientboundAnimatePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundAnimatePacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.animation = Animation.from(in.readUnsignedByte()); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); if (this.animation == null) { out.writeByte(-1); // Client does nothing on unknown ID diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundDamageEventPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundDamageEventPacket.java index f99a3225..a8d267de 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundDamageEventPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundDamageEventPacket.java @@ -6,7 +6,7 @@ import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import org.cloudburstmc.math.vector.Vector3d; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @AllArgsConstructor diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundEntityEventPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundEntityEventPacket.java index 02782f8c..64d99458 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundEntityEventPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundEntityEventPacket.java @@ -9,8 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,13 +16,13 @@ public class ClientboundEntityEventPacket implements MinecraftPacket { private final int entityId; private final @NonNull EntityEvent event; - public ClientboundEntityEventPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundEntityEventPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = in.readInt(); this.event = helper.readEntityEvent(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeInt(this.entityId); helper.writeEntityEvent(out, this.event); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityPosPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityPosPacket.java index 222dfb01..fc50024c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityPosPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityPosPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -19,7 +17,7 @@ public class ClientboundMoveEntityPosPacket implements MinecraftPacket { private final double moveZ; private final boolean onGround; - public ClientboundMoveEntityPosPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundMoveEntityPosPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.moveX = in.readShort() / 4096D; this.moveY = in.readShort() / 4096D; @@ -28,7 +26,7 @@ public class ClientboundMoveEntityPosPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); out.writeShort((int) (this.moveX * 4096)); out.writeShort((int) (this.moveY * 4096)); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityPosRotPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityPosRotPacket.java index 38ca6238..38e46719 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityPosRotPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityPosRotPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -21,7 +19,7 @@ public class ClientboundMoveEntityPosRotPacket implements MinecraftPacket { private final float pitch; private final boolean onGround; - public ClientboundMoveEntityPosRotPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundMoveEntityPosRotPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.moveX = in.readShort() / 4096D; this.moveY = in.readShort() / 4096D; @@ -32,7 +30,7 @@ public class ClientboundMoveEntityPosRotPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); out.writeShort((int) (this.moveX * 4096)); out.writeShort((int) (this.moveY * 4096)); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityRotPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityRotPacket.java index b59a7997..e3ad09e7 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityRotPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveEntityRotPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,7 +16,7 @@ public class ClientboundMoveEntityRotPacket implements MinecraftPacket { private final float pitch; private final boolean onGround; - public ClientboundMoveEntityRotPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundMoveEntityRotPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.yaw = in.readByte() * 360 / 256f; this.pitch = in.readByte() * 360 / 256f; @@ -26,7 +24,7 @@ public class ClientboundMoveEntityRotPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); out.writeByte((byte) (this.yaw * 256 / 360)); out.writeByte((byte) (this.pitch * 256 / 360)); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveVehiclePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveVehiclePacket.java index 052b3aca..e33e2475 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveVehiclePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundMoveVehiclePacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -19,7 +17,7 @@ public class ClientboundMoveVehiclePacket implements MinecraftPacket { private final float yaw; private final float pitch; - public ClientboundMoveVehiclePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundMoveVehiclePacket(ByteBuf in, MinecraftCodecHelper helper) { this.x = in.readDouble(); this.y = in.readDouble(); this.z = in.readDouble(); @@ -28,7 +26,7 @@ public class ClientboundMoveVehiclePacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeDouble(this.x); out.writeDouble(this.y); out.writeDouble(this.z); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRemoveEntitiesPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRemoveEntitiesPacket.java index b75e38f9..8ca78c40 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRemoveEntitiesPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRemoveEntitiesPacket.java @@ -5,18 +5,16 @@ import com.github.steveice10.mc.protocol.codec.MinecraftPacket; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NonNull; import lombok.With; -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; @Data @With @AllArgsConstructor public class ClientboundRemoveEntitiesPacket implements MinecraftPacket { - private final @NotNull int[] entityIds; + private final int @NonNull [] entityIds; - public ClientboundRemoveEntitiesPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundRemoveEntitiesPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityIds = new int[helper.readVarInt(in)]; for (int i = 0; i < this.entityIds.length; i++) { this.entityIds[i] = helper.readVarInt(in); @@ -24,7 +22,7 @@ public class ClientboundRemoveEntitiesPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityIds.length); for (int entityId : this.entityIds) { helper.writeVarInt(out, entityId); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRemoveMobEffectPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRemoveMobEffectPacket.java index 96010b48..554765c2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRemoveMobEffectPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRemoveMobEffectPacket.java @@ -9,8 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,13 +16,13 @@ public class ClientboundRemoveMobEffectPacket implements MinecraftPacket { private final int entityId; private final @NonNull Effect effect; - public ClientboundRemoveMobEffectPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundRemoveMobEffectPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.effect = helper.readEffect(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); helper.writeEffect(out, this.effect); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRotateHeadPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRotateHeadPacket.java index ddc4d0ac..bf9b090b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRotateHeadPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundRotateHeadPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -16,13 +14,13 @@ public class ClientboundRotateHeadPacket implements MinecraftPacket { private final int entityId; private final float headYaw; - public ClientboundRotateHeadPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundRotateHeadPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.headYaw = in.readByte() * 360 / 256f; } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); out.writeByte((byte) (this.headYaw * 256 / 360)); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetEntityLinkPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetEntityLinkPacket.java index 8081ec0d..ef5f2496 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetEntityLinkPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetEntityLinkPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -16,13 +14,13 @@ public class ClientboundSetEntityLinkPacket implements MinecraftPacket { private final int entityId; private final int attachedToId; - public ClientboundSetEntityLinkPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetEntityLinkPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = in.readInt(); this.attachedToId = in.readInt(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeInt(this.entityId); out.writeInt(this.attachedToId); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetEntityMotionPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetEntityMotionPacket.java index a599b8dc..9b85011c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetEntityMotionPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetEntityMotionPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,7 +16,7 @@ public class ClientboundSetEntityMotionPacket implements MinecraftPacket { private final double motionY; private final double motionZ; - public ClientboundSetEntityMotionPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetEntityMotionPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.motionX = in.readShort() / 8000D; this.motionY = in.readShort() / 8000D; @@ -26,7 +24,7 @@ public class ClientboundSetEntityMotionPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); out.writeShort((int) (this.motionX * 8000)); out.writeShort((int) (this.motionY * 8000)); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetPassengersPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetPassengersPacket.java index eaf0fe47..1c3d1edb 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetPassengersPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundSetPassengersPacket.java @@ -8,16 +8,14 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundSetPassengersPacket implements MinecraftPacket { private final int entityId; - private final @NonNull int[] passengerIds; + private final int @NonNull [] passengerIds; - public ClientboundSetPassengersPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetPassengersPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.passengerIds = new int[helper.readVarInt(in)]; for (int index = 0; index < this.passengerIds.length; index++) { @@ -26,7 +24,7 @@ public class ClientboundSetPassengersPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); helper.writeVarInt(out, this.passengerIds.length); for (int entityId : this.passengerIds) { diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundTakeItemEntityPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundTakeItemEntityPacket.java index d90523ff..0d4365d2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundTakeItemEntityPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundTakeItemEntityPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,14 +15,14 @@ public class ClientboundTakeItemEntityPacket implements MinecraftPacket { private final int collectorEntityId; private final int itemCount; - public ClientboundTakeItemEntityPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundTakeItemEntityPacket(ByteBuf in, MinecraftCodecHelper helper) { this.collectedEntityId = helper.readVarInt(in); this.collectorEntityId = helper.readVarInt(in); this.itemCount = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.collectedEntityId); helper.writeVarInt(out, this.collectorEntityId); helper.writeVarInt(out, this.itemCount); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundTeleportEntityPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundTeleportEntityPacket.java index a12d1779..06e73b4a 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundTeleportEntityPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundTeleportEntityPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -21,7 +19,7 @@ public class ClientboundTeleportEntityPacket implements MinecraftPacket { private final float pitch; private final boolean onGround; - public ClientboundTeleportEntityPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundTeleportEntityPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.x = in.readDouble(); this.y = in.readDouble(); @@ -32,7 +30,7 @@ public class ClientboundTeleportEntityPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); out.writeDouble(this.x); out.writeDouble(this.y); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateAttributesPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateAttributesPacket.java index 73f9f40b..f61dd842 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateAttributesPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateAttributesPacket.java @@ -12,7 +12,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -23,7 +22,7 @@ public class ClientboundUpdateAttributesPacket implements MinecraftPacket { private final int entityId; private final @NonNull List attributes; - public ClientboundUpdateAttributesPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundUpdateAttributesPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.attributes = new ArrayList<>(); int length = helper.readVarInt(in); @@ -42,7 +41,7 @@ public class ClientboundUpdateAttributesPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); helper.writeVarInt(out, this.attributes.size()); for (Attribute attribute : this.attributes) { diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateMobEffectPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateMobEffectPacket.java index 8ffff53c..b7a80d65 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateMobEffectPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateMobEffectPacket.java @@ -9,7 +9,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; import lombok.With; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockChangedAckPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockChangedAckPacket.java index 473fb0ac..63376f46 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockChangedAckPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockChangedAckPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundBlockChangedAckPacket implements MinecraftPacket { private final int sequence; - public ClientboundBlockChangedAckPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundBlockChangedAckPacket(ByteBuf in, MinecraftCodecHelper helper) { this.sequence = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.sequence); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerAbilitiesPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerAbilitiesPacket.java index 9471aa87..f6aeae0d 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerAbilitiesPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerAbilitiesPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -25,7 +23,7 @@ public class ClientboundPlayerAbilitiesPacket implements MinecraftPacket { private final float flySpeed; private final float walkSpeed; - public ClientboundPlayerAbilitiesPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundPlayerAbilitiesPacket(ByteBuf in, MinecraftCodecHelper helper) { byte flags = in.readByte(); this.invincible = (flags & FLAG_INVINCIBLE) > 0; this.canFly = (flags & FLAG_CAN_FLY) > 0; @@ -37,7 +35,7 @@ public class ClientboundPlayerAbilitiesPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { int flags = 0; if (this.invincible) { flags |= FLAG_INVINCIBLE; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerCombatEndPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerCombatEndPacket.java index f860ef08..1acc2f3a 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerCombatEndPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerCombatEndPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundPlayerCombatEndPacket implements MinecraftPacket { private final int duration; - public ClientboundPlayerCombatEndPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundPlayerCombatEndPacket(ByteBuf in, MinecraftCodecHelper helper) { this.duration = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.duration); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerCombatEnterPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerCombatEnterPacket.java index 35c9730a..af78eea4 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerCombatEnterPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerCombatEnterPacket.java @@ -7,19 +7,17 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.With; -import java.io.IOException; - @Data @With @NoArgsConstructor public class ClientboundPlayerCombatEnterPacket implements MinecraftPacket { - public ClientboundPlayerCombatEnterPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundPlayerCombatEnterPacket(ByteBuf in, MinecraftCodecHelper helper) { // no-op } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { // no-op } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerLookAtPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerLookAtPacket.java index 7992eecb..19c46958 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerLookAtPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerLookAtPacket.java @@ -9,8 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -27,7 +25,7 @@ public class ClientboundPlayerLookAtPacket implements MinecraftPacket { this(origin, x, y, z, 0, null); } - public ClientboundPlayerLookAtPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundPlayerLookAtPacket(ByteBuf in, MinecraftCodecHelper helper) { this.origin = RotationOrigin.from(helper.readVarInt(in)); this.x = in.readDouble(); this.y = in.readDouble(); @@ -43,7 +41,7 @@ public class ClientboundPlayerLookAtPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.origin.ordinal()); out.writeDouble(this.x); out.writeDouble(this.y); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerPositionPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerPositionPacket.java index 85ad46c7..3250e32b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerPositionPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundPlayerPositionPacket.java @@ -9,7 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -30,7 +29,7 @@ public class ClientboundPlayerPositionPacket implements MinecraftPacket { this(x, y, z, yaw, pitch, teleportId, Arrays.asList(relative != null ? relative : new PositionElement[0])); } - public ClientboundPlayerPositionPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundPlayerPositionPacket(ByteBuf in, MinecraftCodecHelper helper) { this.x = in.readDouble(); this.y = in.readDouble(); this.z = in.readDouble(); @@ -50,7 +49,7 @@ public class ClientboundPlayerPositionPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeDouble(this.x); out.writeDouble(this.y); out.writeDouble(this.z); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetCarriedItemPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetCarriedItemPacket.java index a2499039..9b351f54 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetCarriedItemPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetCarriedItemPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundSetCarriedItemPacket implements MinecraftPacket { private final int slot; - public ClientboundSetCarriedItemPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetCarriedItemPacket(ByteBuf in, MinecraftCodecHelper helper) { this.slot = in.readByte(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeByte(this.slot); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetExperiencePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetExperiencePacket.java index 30b918eb..18008ff2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetExperiencePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetExperiencePacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,14 +15,14 @@ public class ClientboundSetExperiencePacket implements MinecraftPacket { private final int level; private final int totalExperience; - public ClientboundSetExperiencePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetExperiencePacket(ByteBuf in, MinecraftCodecHelper helper) { this.experience = in.readFloat(); this.level = helper.readVarInt(in); this.totalExperience = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeFloat(this.experience); helper.writeVarInt(out, this.level); helper.writeVarInt(out, this.totalExperience); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetHealthPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetHealthPacket.java index d3913595..63f44143 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetHealthPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundSetHealthPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,14 +15,14 @@ public class ClientboundSetHealthPacket implements MinecraftPacket { private final int food; private final float saturation; - public ClientboundSetHealthPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetHealthPacket(ByteBuf in, MinecraftCodecHelper helper) { this.health = in.readFloat(); this.food = helper.readVarInt(in); this.saturation = in.readFloat(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeFloat(this.health); helper.writeVarInt(out, this.food); out.writeFloat(this.saturation); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddEntityPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddEntityPacket.java index 7d0cecff..7e5ec27a 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddEntityPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddEntityPacket.java @@ -10,7 +10,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; import java.util.UUID; @Data @@ -49,7 +48,7 @@ public class ClientboundAddEntityPacket implements MinecraftPacket { this(entityId, uuid, type, EMPTY_DATA, x, y, z, yaw, headYaw, pitch, motionX, motionY, motionZ); } - public ClientboundAddEntityPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundAddEntityPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.uuid = helper.readUUID(in); this.type = EntityType.from(helper.readVarInt(in)); @@ -88,7 +87,7 @@ public class ClientboundAddEntityPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); helper.writeUUID(out, this.uuid); helper.writeVarInt(out, this.type.ordinal()); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddExperienceOrbPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddExperienceOrbPacket.java index 9b39894c..70b213c2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddExperienceOrbPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddExperienceOrbPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -19,7 +17,7 @@ public class ClientboundAddExperienceOrbPacket implements MinecraftPacket { private final double z; private final int exp; - public ClientboundAddExperienceOrbPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundAddExperienceOrbPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.x = in.readDouble(); this.y = in.readDouble(); @@ -28,7 +26,7 @@ public class ClientboundAddExperienceOrbPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); out.writeDouble(this.x); out.writeDouble(this.y); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerClosePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerClosePacket.java index bc32f27c..a5f18f07 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerClosePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerClosePacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundContainerClosePacket implements MinecraftPacket { private final int containerId; - public ClientboundContainerClosePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundContainerClosePacket(ByteBuf in, MinecraftCodecHelper helper) { this.containerId = in.readUnsignedByte(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeByte(this.containerId); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetContentPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetContentPacket.java index a7e0921b..1f870a60 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetContentPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetContentPacket.java @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; import lombok.With; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetDataPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetDataPacket.java index 3671db67..cf417e23 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetDataPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetDataPacket.java @@ -8,8 +8,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -22,14 +20,14 @@ public class ClientboundContainerSetDataPacket implements MinecraftPacket { this(containerId, rawProperty.ordinal(), value); } - public ClientboundContainerSetDataPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundContainerSetDataPacket(ByteBuf in, MinecraftCodecHelper helper) { this.containerId = in.readUnsignedByte(); this.rawProperty = in.readShort(); this.value = in.readShort(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeByte(this.containerId); out.writeShort(this.rawProperty); out.writeShort(this.value); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetSlotPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetSlotPacket.java index 1edbe93c..66d6b537 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetSlotPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundContainerSetSlotPacket.java @@ -7,7 +7,7 @@ import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundHorseScreenOpenPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundHorseScreenOpenPacket.java index fab955fd..df929f01 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundHorseScreenOpenPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundHorseScreenOpenPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,14 +15,14 @@ public class ClientboundHorseScreenOpenPacket implements MinecraftPacket { private final int numberOfSlots; private final int entityId; - public ClientboundHorseScreenOpenPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundHorseScreenOpenPacket(ByteBuf in, MinecraftCodecHelper helper) { this.containerId = in.readByte(); this.numberOfSlots = helper.readVarInt(in); this.entityId = in.readInt(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeByte(this.containerId); helper.writeVarInt(out, this.numberOfSlots); out.writeInt(this.entityId); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundOpenBookPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundOpenBookPacket.java index ce566f74..8ee2ee2d 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundOpenBookPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundOpenBookPacket.java @@ -9,20 +9,18 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundOpenBookPacket implements MinecraftPacket { private final @NonNull Hand hand; - public ClientboundOpenBookPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundOpenBookPacket(ByteBuf in, MinecraftCodecHelper helper) { this.hand = Hand.from(helper.readVarInt(in)); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.hand.ordinal()); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundPlaceGhostRecipePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundPlaceGhostRecipePacket.java index f949cc2d..9b39dbe3 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundPlaceGhostRecipePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/inventory/ClientboundPlaceGhostRecipePacket.java @@ -8,8 +8,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,13 +15,13 @@ public class ClientboundPlaceGhostRecipePacket implements MinecraftPacket { private final int containerId; private final @NonNull String recipeId; - public ClientboundPlaceGhostRecipePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundPlaceGhostRecipePacket(ByteBuf in, MinecraftCodecHelper helper) { this.containerId = in.readByte(); this.recipeId = helper.readString(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeByte(this.containerId); helper.writeString(out, this.recipeId); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockDestructionPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockDestructionPacket.java index 31aca711..4f6edb27 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockDestructionPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockDestructionPacket.java @@ -10,8 +10,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -20,14 +18,14 @@ public class ClientboundBlockDestructionPacket implements MinecraftPacket { private final @NonNull Vector3i position; private final @NonNull BlockBreakStage stage; - public ClientboundBlockDestructionPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundBlockDestructionPacket(ByteBuf in, MinecraftCodecHelper helper) { this.breakerEntityId = helper.readVarInt(in); this.position = helper.readPosition(in); this.stage = helper.readBlockBreakStage(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.breakerEntityId); helper.writePosition(out, this.position); helper.writeBlockBreakStage(out, this.stage); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockEntityDataPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockEntityDataPacket.java index e3846307..7860b2b3 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockEntityDataPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockEntityDataPacket.java @@ -10,7 +10,7 @@ import lombok.Data; import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockUpdatePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockUpdatePacket.java index 602f802c..3d283941 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockUpdatePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundBlockUpdatePacket.java @@ -9,20 +9,18 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundBlockUpdatePacket implements MinecraftPacket { private final @NonNull BlockChangeEntry entry; - public ClientboundBlockUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundBlockUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) { this.entry = new BlockChangeEntry(helper.readPosition(in), helper.readVarInt(in)); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writePosition(out, this.entry.getPosition()); helper.writeVarInt(out, this.entry.getBlock()); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchFinishedPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchFinishedPacket.java index 49d173c7..8273a816 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchFinishedPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchFinishedPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -19,7 +17,7 @@ public class ClientboundChunkBatchFinishedPacket implements MinecraftPacket { this.batchSize = helper.readVarInt(in); } - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.batchSize); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchStartPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchStartPacket.java index 24f52584..6f33ad78 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchStartPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchStartPacket.java @@ -6,8 +6,6 @@ import io.netty.buffer.ByteBuf; import lombok.Data; import lombok.NoArgsConstructor; -import java.io.IOException; - @Data @NoArgsConstructor public class ClientboundChunkBatchStartPacket implements MinecraftPacket { @@ -15,6 +13,6 @@ public class ClientboundChunkBatchStartPacket implements MinecraftPacket { public ClientboundChunkBatchStartPacket(ByteBuf in, MinecraftCodecHelper helper) { } - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundForgetLevelChunkPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundForgetLevelChunkPacket.java index ec0df69b..bfc5067d 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundForgetLevelChunkPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundForgetLevelChunkPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -16,14 +14,14 @@ public class ClientboundForgetLevelChunkPacket implements MinecraftPacket { private final int x; private final int z; - public ClientboundForgetLevelChunkPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundForgetLevelChunkPacket(ByteBuf in, MinecraftCodecHelper helper) { long chunkPosition = in.readLong(); this.x = (int)chunkPosition; this.z = (int)(chunkPosition >> 32); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeLong(this.x & 0xFFFFFFFFL | (this.z & 0xFFFFFFFFL) << 32); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelEventPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelEventPacket.java index 1983566f..4bd9fe3f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelEventPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelEventPacket.java @@ -11,8 +11,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -30,48 +28,22 @@ public class ClientboundLevelEventPacket implements MinecraftPacket { this.event = helper.readLevelEvent(in); this.position = helper.readPosition(in); int value = in.readInt(); - if (this.event instanceof LevelEventType) { - switch ((LevelEventType) this.event) { - case BLOCK_FIRE_EXTINGUISH: - this.data = FireExtinguishData.from(value); - break; - case RECORD: - this.data = new RecordEventData(value); - break; - case SMOKE: - case WHITE_SMOKE: - this.data = new SmokeEventData(Direction.from(Math.abs(value % 6))); - break; - case BREAK_BLOCK: - case BRUSH_BLOCK_COMPLETE: - this.data = new BreakBlockEventData(value); - break; - case BREAK_SPLASH_POTION: - case BREAK_SPLASH_POTION2: - this.data = new BreakPotionEventData(value); - break; - case BONEMEAL_GROW: - case BONEMEAL_GROW_WITH_SOUND: - this.data = new BonemealGrowEventData(value); - break; - case COMPOSTER: - this.data = value > 0 ? ComposterEventData.FILL_SUCCESS : ComposterEventData.FILL; - break; - case ENDERDRAGON_FIREBALL_EXPLODE: - this.data = value == 1 ? DragonFireballEventData.HAS_SOUND : DragonFireballEventData.NO_SOUND; - break; - case ELECTRIC_SPARK: - this.data = value >= 0 && value < 6 ? new ElectricSparkData(Direction.from(value)) : new UnknownLevelEventData(value); - break; - case SCULK_BLOCK_CHARGE: - this.data = new SculkBlockChargeEventData(value); - break; - case TRIAL_SPAWNER_DETECT_PLAYER: - this.data = new TrialSpawnerDetectEventData(value); - break; - default: - this.data = new UnknownLevelEventData(value); - break; + if (this.event instanceof LevelEventType levelEventType) { + switch (levelEventType) { + case BLOCK_FIRE_EXTINGUISH -> this.data = FireExtinguishData.from(value); + case RECORD -> this.data = new RecordEventData(value); + case SMOKE, WHITE_SMOKE -> this.data = new SmokeEventData(Direction.from(Math.abs(value % 6))); + case BREAK_BLOCK, BRUSH_BLOCK_COMPLETE -> this.data = new BreakBlockEventData(value); + case BREAK_SPLASH_POTION, BREAK_SPLASH_POTION2 -> this.data = new BreakPotionEventData(value); + case BONEMEAL_GROW, BONEMEAL_GROW_WITH_SOUND -> this.data = new BonemealGrowEventData(value); + case COMPOSTER -> this.data = value > 0 ? ComposterEventData.FILL_SUCCESS : ComposterEventData.FILL; + case ENDERDRAGON_FIREBALL_EXPLODE -> + this.data = value == 1 ? DragonFireballEventData.HAS_SOUND : DragonFireballEventData.NO_SOUND; + case ELECTRIC_SPARK -> + this.data = value >= 0 && value < 6 ? new ElectricSparkData(Direction.from(value)) : new UnknownLevelEventData(value); + case SCULK_BLOCK_CHARGE -> this.data = new SculkBlockChargeEventData(value); + case TRIAL_SPAWNER_DETECT_PLAYER -> this.data = new TrialSpawnerDetectEventData(value); + default -> this.data = new UnknownLevelEventData(value); } } else { this.data = new UnknownLevelEventData(value); @@ -81,7 +53,7 @@ public class ClientboundLevelEventPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeLevelEvent(out, this.event); helper.writePosition(out, this.position); int value; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelParticlesPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelParticlesPacket.java index afb6af59..d3b0b5e2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelParticlesPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelParticlesPacket.java @@ -3,7 +3,6 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.codec.MinecraftPacket; import com.github.steveice10.mc.protocol.data.game.level.particle.Particle; -import com.github.steveice10.mc.protocol.data.game.level.particle.ParticleData; import com.github.steveice10.mc.protocol.data.game.level.particle.ParticleType; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLightUpdatePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLightUpdatePacket.java index 1a6cb327..6c12bd19 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLightUpdatePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLightUpdatePacket.java @@ -8,9 +8,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; import lombok.With; -import org.jetbrains.annotations.NotNull; -import java.io.IOException; import java.util.BitSet; import java.util.List; @@ -20,7 +18,7 @@ import java.util.List; public class ClientboundLightUpdatePacket implements MinecraftPacket { private final int x; private final int z; - private final @NotNull LightUpdateData lightData; + private final @NonNull LightUpdateData lightData; public ClientboundLightUpdatePacket(int x, int z, @NonNull BitSet skyYMask, @NonNull BitSet blockYMask, @NonNull BitSet emptySkyYMask, @NonNull BitSet emptyBlockYMask, @@ -40,14 +38,14 @@ public class ClientboundLightUpdatePacket implements MinecraftPacket { this.lightData = new LightUpdateData(skyYMask, blockYMask, emptySkyYMask, emptyBlockYMask, skyUpdates, blockUpdates); } - public ClientboundLightUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundLightUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) { this.x = helper.readVarInt(in); this.z = helper.readVarInt(in); this.lightData = helper.readLightUpdateData(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.x); helper.writeVarInt(out, this.z); helper.writeLightUpdateData(out, this.lightData); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundMapItemDataPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundMapItemDataPacket.java index 5b9ba41d..a7348862 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundMapItemDataPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundMapItemDataPacket.java @@ -2,7 +2,6 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.codec.MinecraftPacket; -import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; import com.github.steveice10.mc.protocol.data.game.level.map.MapData; import com.github.steveice10.mc.protocol.data.game.level.map.MapIcon; import com.github.steveice10.mc.protocol.data.game.level.map.MapIconType; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundOpenSignEditorPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundOpenSignEditorPacket.java index 598be3a9..12966f0f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundOpenSignEditorPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundOpenSignEditorPacket.java @@ -9,8 +9,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,13 +16,13 @@ public class ClientboundOpenSignEditorPacket implements MinecraftPacket { private final @NonNull Vector3i position; private final boolean isFrontText; - public ClientboundOpenSignEditorPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundOpenSignEditorPacket(ByteBuf in, MinecraftCodecHelper helper) { this.position = helper.readPosition(in); this.isFrontText = in.readBoolean(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writePosition(out, this.position); out.writeBoolean(this.isFrontText); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSectionBlocksUpdatePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSectionBlocksUpdatePacket.java index 59b25dbe..fb341cb0 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSectionBlocksUpdatePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSectionBlocksUpdatePacket.java @@ -9,8 +9,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; - @Data @With public class ClientboundSectionBlocksUpdatePacket implements MinecraftPacket { @@ -33,7 +31,7 @@ public class ClientboundSectionBlocksUpdatePacket implements MinecraftPacket { this.entries = entries; } - public ClientboundSectionBlocksUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSectionBlocksUpdatePacket(ByteBuf in, MinecraftCodecHelper helper) { long chunkPosition = in.readLong(); this.chunkX = (int) (chunkPosition >> 42); this.chunkY = (int) (chunkPosition << 44 >> 44); @@ -50,7 +48,7 @@ public class ClientboundSectionBlocksUpdatePacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { long chunkPosition = 0; chunkPosition |= (this.chunkX & 0x3FFFFFL) << 42; chunkPosition |= (this.chunkZ & 0x3FFFFFL) << 20; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetChunkCacheCenterPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetChunkCacheCenterPacket.java index 0304fde2..e7ad047e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetChunkCacheCenterPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetChunkCacheCenterPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -16,13 +14,13 @@ public class ClientboundSetChunkCacheCenterPacket implements MinecraftPacket { private final int chunkX; private final int chunkZ; - public ClientboundSetChunkCacheCenterPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetChunkCacheCenterPacket(ByteBuf in, MinecraftCodecHelper helper) { this.chunkX = helper.readVarInt(in); this.chunkZ = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.chunkX); helper.writeVarInt(out, this.chunkZ); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetChunkCacheRadiusPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetChunkCacheRadiusPacket.java index a24dcbea..857b67ac 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetChunkCacheRadiusPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetChunkCacheRadiusPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundSetChunkCacheRadiusPacket implements MinecraftPacket { private final int viewDistance; - public ClientboundSetChunkCacheRadiusPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetChunkCacheRadiusPacket(ByteBuf in, MinecraftCodecHelper helper) { this.viewDistance = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.viewDistance); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetDefaultSpawnPositionPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetDefaultSpawnPositionPacket.java index e64342bc..fcc9e0ae 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetDefaultSpawnPositionPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetDefaultSpawnPositionPacket.java @@ -9,8 +9,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,13 +16,13 @@ public class ClientboundSetDefaultSpawnPositionPacket implements MinecraftPacket private final @NonNull Vector3i position; private final float angle; - public ClientboundSetDefaultSpawnPositionPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetDefaultSpawnPositionPacket(ByteBuf in, MinecraftCodecHelper helper) { this.position = helper.readPosition(in); this.angle = in.readFloat(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writePosition(out, this.position); out.writeFloat(this.angle); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetSimulationDistancePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetSimulationDistancePacket.java index 4d25a227..233ea685 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetSimulationDistancePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetSimulationDistancePacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundSetSimulationDistancePacket implements MinecraftPacket { private final int simulationDistance; - public ClientboundSetSimulationDistancePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetSimulationDistancePacket(ByteBuf in, MinecraftCodecHelper helper) { this.simulationDistance = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.simulationDistance); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetTimePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetTimePacket.java index 394a07f0..bea56555 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetTimePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetTimePacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -16,13 +14,13 @@ public class ClientboundSetTimePacket implements MinecraftPacket { private final long worldAge; private final long time; - public ClientboundSetTimePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetTimePacket(ByteBuf in, MinecraftCodecHelper helper) { this.worldAge = in.readLong(); this.time = in.readLong(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeLong(this.worldAge); out.writeLong(this.time); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSoundPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSoundPacket.java index d7934f06..40fb79ca 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSoundPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSoundPacket.java @@ -12,8 +12,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -39,7 +37,7 @@ public class ClientboundSoundPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { if (this.sound instanceof CustomSound) { helper.writeVarInt(out, 0); helper.writeSoundEvent(out, this.sound); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundTagQueryPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundTagQueryPacket.java index 44633e9f..43492f7a 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundTagQueryPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundTagQueryPacket.java @@ -7,7 +7,7 @@ import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundInitializeBorderPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundInitializeBorderPacket.java index 33280b78..9a41bb89 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundInitializeBorderPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundInitializeBorderPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -22,7 +20,7 @@ public class ClientboundInitializeBorderPacket implements MinecraftPacket { private final int warningBlocks; private final int warningTime; - public ClientboundInitializeBorderPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundInitializeBorderPacket(ByteBuf in, MinecraftCodecHelper helper) { this.newCenterX = in.readDouble(); this.newCenterZ = in.readDouble(); this.oldSize = in.readDouble(); @@ -34,7 +32,7 @@ public class ClientboundInitializeBorderPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeDouble(this.newCenterX); out.writeDouble(this.newCenterZ); out.writeDouble(this.oldSize); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderCenterPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderCenterPacket.java index a0dc2831..2baa4af9 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderCenterPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderCenterPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -16,13 +14,13 @@ public class ClientboundSetBorderCenterPacket implements MinecraftPacket { private final double newCenterX; private final double newCenterZ; - public ClientboundSetBorderCenterPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetBorderCenterPacket(ByteBuf in, MinecraftCodecHelper helper) { this.newCenterX = in.readDouble(); this.newCenterZ = in.readDouble(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeDouble(this.newCenterX); out.writeDouble(this.newCenterZ); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderLerpSizePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderLerpSizePacket.java index 34903edd..e1053c3d 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderLerpSizePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderLerpSizePacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,14 +15,14 @@ public class ClientboundSetBorderLerpSizePacket implements MinecraftPacket { private final double newSize; private final long lerpTime; - public ClientboundSetBorderLerpSizePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetBorderLerpSizePacket(ByteBuf in, MinecraftCodecHelper helper) { this.oldSize = in.readDouble(); this.newSize = in.readDouble(); this.lerpTime = helper.readVarLong(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeDouble(this.oldSize); out.writeDouble(this.newSize); helper.writeVarLong(out, this.lerpTime); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderSizePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderSizePacket.java index d275f015..2677f276 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderSizePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderSizePacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundSetBorderSizePacket implements MinecraftPacket { private final double size; - public ClientboundSetBorderSizePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetBorderSizePacket(ByteBuf in, MinecraftCodecHelper helper) { this.size = in.readDouble(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeDouble(this.size); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderWarningDelayPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderWarningDelayPacket.java index fb871eff..f9c9e6f2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderWarningDelayPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderWarningDelayPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundSetBorderWarningDelayPacket implements MinecraftPacket { private final int warningDelay; - public ClientboundSetBorderWarningDelayPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetBorderWarningDelayPacket(ByteBuf in, MinecraftCodecHelper helper) { this.warningDelay = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.warningDelay); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderWarningDistancePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderWarningDistancePacket.java index 24767f33..05434501 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderWarningDistancePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/border/ClientboundSetBorderWarningDistancePacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundSetBorderWarningDistancePacket implements MinecraftPacket { private final int warningBlocks; - public ClientboundSetBorderWarningDistancePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetBorderWarningDistancePacket(ByteBuf in, MinecraftCodecHelper helper) { this.warningBlocks = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.warningBlocks); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundResetScorePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundResetScorePacket.java index 775d844a..15feab8e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundResetScorePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundResetScorePacket.java @@ -7,9 +7,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; import lombok.With; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @With @@ -25,7 +23,7 @@ public class ClientboundResetScorePacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeString(out, this.owner); helper.writeNullable(out, this.objective, helper::writeString); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetDisplayObjectivePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetDisplayObjectivePacket.java index 037b01ad..6c43c127 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetDisplayObjectivePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetDisplayObjectivePacket.java @@ -9,8 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,13 +16,13 @@ public class ClientboundSetDisplayObjectivePacket implements MinecraftPacket { private final @NonNull ScoreboardPosition position; private final @NonNull String name; - public ClientboundSetDisplayObjectivePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetDisplayObjectivePacket(ByteBuf in, MinecraftCodecHelper helper) { this.position = ScoreboardPosition.from(helper.readVarInt(in)); this.name = helper.readString(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.position.ordinal()); helper.writeString(out, this.name); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetObjectivePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetObjectivePacket.java index c4c2508d..98e66a24 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetObjectivePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetObjectivePacket.java @@ -10,7 +10,7 @@ import lombok.Data; import lombok.NonNull; import lombok.With; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetPlayerTeamPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetPlayerTeamPacket.java index bee4c378..2cb12d51 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetPlayerTeamPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetPlayerTeamPacket.java @@ -9,7 +9,7 @@ import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor; import io.netty.buffer.ByteBuf; import lombok.*; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; import java.util.Arrays; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetScorePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetScorePacket.java index 066ff950..3f32003b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetScorePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetScorePacket.java @@ -6,7 +6,7 @@ import com.github.steveice10.mc.protocol.data.game.chat.numbers.NumberFormat; import io.netty.buffer.ByteBuf; import lombok.*; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundClearTitlesPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundClearTitlesPacket.java index b20402c8..52a466c9 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundClearTitlesPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundClearTitlesPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundClearTitlesPacket implements MinecraftPacket { private final boolean resetTimes; - public ClientboundClearTitlesPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundClearTitlesPacket(ByteBuf in, MinecraftCodecHelper helper) { this.resetTimes = in.readBoolean(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeBoolean(this.resetTimes); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetActionBarTextPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetActionBarTextPacket.java index 894b55c8..d6443eba 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetActionBarTextPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetActionBarTextPacket.java @@ -2,7 +2,6 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound.title; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.codec.MinecraftPacket; -import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetSubtitleTextPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetSubtitleTextPacket.java index ec277fc7..ee1deaca 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetSubtitleTextPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetSubtitleTextPacket.java @@ -2,7 +2,6 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound.title; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.codec.MinecraftPacket; -import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetTitleTextPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetTitleTextPacket.java index 6ffbe57c..b60d7bdf 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetTitleTextPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetTitleTextPacket.java @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; @@ -23,7 +23,7 @@ public class ClientboundSetTitleTextPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeString(out, DefaultComponentSerializer.get().serializeOr(this.text, "null")); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetTitlesAnimationPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetTitlesAnimationPacket.java index ea8fa5ee..b49cadca 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetTitlesAnimationPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/title/ClientboundSetTitlesAnimationPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,14 +15,14 @@ public class ClientboundSetTitlesAnimationPacket implements MinecraftPacket { private final int stay; private final int fadeOut; - public ClientboundSetTitlesAnimationPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundSetTitlesAnimationPacket(ByteBuf in, MinecraftCodecHelper helper) { this.fadeIn = in.readInt(); this.stay = in.readInt(); this.fadeOut = in.readInt(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeInt(this.fadeIn); out.writeInt(this.stay); out.writeInt(this.fadeOut); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChangeDifficultyPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChangeDifficultyPacket.java index b0699b63..8ac49ac1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChangeDifficultyPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChangeDifficultyPacket.java @@ -9,20 +9,18 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundChangeDifficultyPacket implements MinecraftPacket { private final @NonNull Difficulty difficulty; - public ServerboundChangeDifficultyPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundChangeDifficultyPacket(ByteBuf in, MinecraftCodecHelper helper) { this.difficulty = Difficulty.from(in.readByte()); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeByte(this.difficulty.ordinal()); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatAckPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatAckPacket.java index c2ed486d..f3045c9e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatAckPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatAckPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundChatAckPacket implements MinecraftPacket { private final int offset; - public ServerboundChatAckPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundChatAckPacket(ByteBuf in, MinecraftCodecHelper helper) { this.offset = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.offset); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatCommandPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatCommandPacket.java index 3ba91f51..6a0c57b9 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatCommandPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatCommandPacket.java @@ -8,7 +8,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; import java.util.ArrayList; import java.util.BitSet; import java.util.List; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPacket.java index 49b447ab..fa73804c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPacket.java @@ -5,21 +5,20 @@ import com.github.steveice10.mc.protocol.codec.MinecraftPacket; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NonNull; import lombok.With; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; -import java.io.IOException; import java.util.BitSet; @Data @With @AllArgsConstructor public class ServerboundChatPacket implements MinecraftPacket { - private final @NotNull String message; + private final @NonNull String message; private final long timeStamp; private final long salt; - private final byte @Nullable[] signature; + private final byte @Nullable [] signature; private final int offset; private final BitSet acknowledgedMessages; @@ -39,7 +38,7 @@ public class ServerboundChatPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeString(out, this.message); out.writeLong(this.timeStamp); out.writeLong(this.salt); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatSessionUpdatePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatSessionUpdatePacket.java index 7b66ca01..13caf1fd 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatSessionUpdatePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatSessionUpdatePacket.java @@ -29,7 +29,7 @@ public class ServerboundChatSessionUpdatePacket implements MinecraftPacket { byte[] keyBytes = helper.readByteArray(in); this.keySignature = helper.readByteArray(in); - PublicKey publicKey = null; + PublicKey publicKey; try { publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(keyBytes)); } catch (GeneralSecurityException e) { @@ -40,7 +40,7 @@ public class ServerboundChatSessionUpdatePacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeUUID(out, this.sessionId); out.writeLong(this.expiresAt); helper.writeByteArray(out, this.publicKey.getEncoded()); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundClientCommandPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundClientCommandPacket.java index 93a64925..febb0a75 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundClientCommandPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundClientCommandPacket.java @@ -9,20 +9,18 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundClientCommandPacket implements MinecraftPacket { private final @NonNull ClientCommand request; - public ServerboundClientCommandPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundClientCommandPacket(ByteBuf in, MinecraftCodecHelper helper) { this.request = ClientCommand.from(helper.readVarInt(in)); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.request.ordinal()); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundCommandSuggestionPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundCommandSuggestionPacket.java index e3c59fdd..de991ed6 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundCommandSuggestionPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundCommandSuggestionPacket.java @@ -8,8 +8,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,13 +15,13 @@ public class ServerboundCommandSuggestionPacket implements MinecraftPacket { private final int transactionId; private final @NonNull String text; - public ServerboundCommandSuggestionPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundCommandSuggestionPacket(ByteBuf in, MinecraftCodecHelper helper) { this.transactionId = helper.readVarInt(in); this.text = helper.readString(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.transactionId); helper.writeString(out, this.text); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundConfigurationAcknowledgedPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundConfigurationAcknowledgedPacket.java index 85b2815f..e8c5dd7f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundConfigurationAcknowledgedPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundConfigurationAcknowledgedPacket.java @@ -6,8 +6,6 @@ import io.netty.buffer.ByteBuf; import lombok.Data; import lombok.NoArgsConstructor; -import java.io.IOException; - @Data @NoArgsConstructor public class ServerboundConfigurationAcknowledgedPacket implements MinecraftPacket { diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundLockDifficultyPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundLockDifficultyPacket.java index 8e3617b7..4f63e23e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundLockDifficultyPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundLockDifficultyPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundLockDifficultyPacket implements MinecraftPacket { private final boolean locked; - public ServerboundLockDifficultyPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundLockDifficultyPacket(ByteBuf in, MinecraftCodecHelper helper) { this.locked = in.readBoolean(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeBoolean(this.locked); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerButtonClickPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerButtonClickPacket.java index ddf7ab48..529a04a1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerButtonClickPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerButtonClickPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -16,13 +14,13 @@ public class ServerboundContainerButtonClickPacket implements MinecraftPacket { private final int containerId; private final int buttonId; - public ServerboundContainerButtonClickPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundContainerButtonClickPacket(ByteBuf in, MinecraftCodecHelper helper) { this.containerId = in.readByte(); this.buttonId = in.readByte(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeByte(this.containerId); out.writeByte(this.buttonId); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerClickPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerClickPacket.java index 9803a267..8bd3234e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerClickPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerClickPacket.java @@ -18,7 +18,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import lombok.Data; import lombok.NonNull; import lombok.With; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; import java.util.Map; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerClosePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerClosePacket.java index 4d1b4015..a416aa66 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerClosePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerClosePacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundContainerClosePacket implements MinecraftPacket { private final int containerId; - public ServerboundContainerClosePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundContainerClosePacket(ByteBuf in, MinecraftCodecHelper helper) { this.containerId = in.readByte(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeByte(this.containerId); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerSlotStateChangedPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerSlotStateChangedPacket.java index 9d859e3d..b942f29e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerSlotStateChangedPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundContainerSlotStateChangedPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -25,7 +23,7 @@ public class ServerboundContainerSlotStateChangedPacket implements MinecraftPack } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.slotId); helper.writeVarInt(out, this.containerId); out.writeBoolean(this.newState); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundEditBookPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundEditBookPacket.java index 3818c9a6..d2744fe4 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundEditBookPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundEditBookPacket.java @@ -6,9 +6,8 @@ import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -20,7 +19,7 @@ public class ServerboundEditBookPacket implements MinecraftPacket { private final List pages; private final @Nullable String title; - public ServerboundEditBookPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundEditBookPacket(ByteBuf in, MinecraftCodecHelper helper) { this.slot = helper.readVarInt(in); this.pages = new ArrayList<>(); int pagesSize = helper.readVarInt(in); @@ -35,7 +34,7 @@ public class ServerboundEditBookPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, slot); helper.writeVarInt(out, this.pages.size()); for (String page : this.pages) { diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemPacket.java index d7c196e3..45ee9e67 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundPickItemPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundPickItemPacket implements MinecraftPacket { private final int slot; - public ServerboundPickItemPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundPickItemPacket(ByteBuf in, MinecraftCodecHelper helper) { this.slot = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.slot); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundPlaceRecipePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundPlaceRecipePacket.java index 37e0c023..68da26e8 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundPlaceRecipePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundPlaceRecipePacket.java @@ -8,8 +8,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,14 +16,14 @@ public class ServerboundPlaceRecipePacket implements MinecraftPacket { private final @NonNull String recipeId; private final boolean makeAll; - public ServerboundPlaceRecipePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundPlaceRecipePacket(ByteBuf in, MinecraftCodecHelper helper) { this.containerId = in.readByte(); this.recipeId = helper.readString(in); this.makeAll = in.readBoolean(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeByte(this.containerId); helper.writeString(out, this.recipeId); out.writeBoolean(this.makeAll); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRecipeBookChangeSettingsPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRecipeBookChangeSettingsPacket.java index 088c7870..0622b2f1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRecipeBookChangeSettingsPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRecipeBookChangeSettingsPacket.java @@ -9,8 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -19,14 +17,14 @@ public class ServerboundRecipeBookChangeSettingsPacket implements MinecraftPacke private final boolean bookOpen; private final boolean filterActive; - public ServerboundRecipeBookChangeSettingsPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundRecipeBookChangeSettingsPacket(ByteBuf in, MinecraftCodecHelper helper) { this.type = CraftingBookStateType.from(helper.readVarInt(in)); this.bookOpen = in.readBoolean(); this.filterActive = in.readBoolean(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.type.ordinal()); out.writeBoolean(this.bookOpen); out.writeBoolean(this.filterActive); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRecipeBookSeenRecipePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRecipeBookSeenRecipePacket.java index 350b8bc8..6dfd43e9 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRecipeBookSeenRecipePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRecipeBookSeenRecipePacket.java @@ -8,20 +8,18 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundRecipeBookSeenRecipePacket implements MinecraftPacket { private final @NonNull String recipeId; - public ServerboundRecipeBookSeenRecipePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundRecipeBookSeenRecipePacket(ByteBuf in, MinecraftCodecHelper helper) { this.recipeId = helper.readString(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeString(out, this.recipeId); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRenameItemPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRenameItemPacket.java index 75a2f05d..03b2455a 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRenameItemPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundRenameItemPacket.java @@ -8,20 +8,18 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundRenameItemPacket implements MinecraftPacket { private final @NonNull String name; - public ServerboundRenameItemPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundRenameItemPacket(ByteBuf in, MinecraftCodecHelper helper) { this.name = helper.readString(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeString(out, this.name); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSeenAdvancementsPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSeenAdvancementsPacket.java index 584efbc1..81e731f2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSeenAdvancementsPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSeenAdvancementsPacket.java @@ -43,14 +43,9 @@ public class ServerboundSeenAdvancementsPacket implements MinecraftPacket { public ServerboundSeenAdvancementsPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { this.action = AdvancementTabAction.from(helper.readVarInt(in)); switch (this.action) { - case CLOSED_SCREEN: - this.tabId = null; - break; - case OPENED_TAB: - this.tabId = helper.readString(in); - break; - default: - throw new IOException("Unknown advancement tab action: " + this.action); + case CLOSED_SCREEN -> this.tabId = null; + case OPENED_TAB -> this.tabId = helper.readString(in); + default -> throw new IOException("Unknown advancement tab action: " + this.action); } } @@ -58,13 +53,10 @@ public class ServerboundSeenAdvancementsPacket implements MinecraftPacket { public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { helper.writeVarInt(out, this.action.ordinal()); switch (this.action) { - case CLOSED_SCREEN: - break; - case OPENED_TAB: - helper.writeString(out, this.tabId); - break; - default: - throw new IOException("Unknown advancement tab action: " + this.action); + case CLOSED_SCREEN -> { + } + case OPENED_TAB -> helper.writeString(out, this.tabId); + default -> throw new IOException("Unknown advancement tab action: " + this.action); } } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSelectTradePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSelectTradePacket.java index cb914923..64c68af4 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSelectTradePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSelectTradePacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundSelectTradePacket implements MinecraftPacket { private final int slot; - public ServerboundSelectTradePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundSelectTradePacket(ByteBuf in, MinecraftCodecHelper helper) { this.slot = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.slot); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetBeaconPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetBeaconPacket.java index e1891acc..988f7f9c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetBeaconPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetBeaconPacket.java @@ -7,7 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; import java.util.OptionalInt; @Data @@ -17,7 +16,7 @@ public class ServerboundSetBeaconPacket implements MinecraftPacket { private final OptionalInt primaryEffect; private final OptionalInt secondaryEffect; - public ServerboundSetBeaconPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundSetBeaconPacket(ByteBuf in, MinecraftCodecHelper helper) { if (in.readBoolean()) { this.primaryEffect = OptionalInt.of(helper.readVarInt(in)); } else { @@ -32,7 +31,7 @@ public class ServerboundSetBeaconPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeBoolean(this.primaryEffect.isPresent()); if (this.primaryEffect.isPresent()) { helper.writeVarInt(out, this.primaryEffect.getAsInt()); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCommandBlockPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCommandBlockPacket.java index 2b10f82d..a63eea4f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCommandBlockPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCommandBlockPacket.java @@ -10,8 +10,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -27,7 +25,7 @@ public class ServerboundSetCommandBlockPacket implements MinecraftPacket { private final boolean conditional; private final boolean automatic; - public ServerboundSetCommandBlockPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundSetCommandBlockPacket(ByteBuf in, MinecraftCodecHelper helper) { this.position = helper.readPosition(in); this.command = helper.readString(in); this.mode = CommandBlockMode.from(helper.readVarInt(in)); @@ -39,7 +37,7 @@ public class ServerboundSetCommandBlockPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writePosition(out, this.position); helper.writeString(out, this.command); helper.writeVarInt(out, this.mode.ordinal()); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCommandMinecartPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCommandMinecartPacket.java index 74782dd0..37b96068 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCommandMinecartPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCommandMinecartPacket.java @@ -8,8 +8,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,14 +16,14 @@ public class ServerboundSetCommandMinecartPacket implements MinecraftPacket { private final @NonNull String command; private final boolean doesTrackOutput; - public ServerboundSetCommandMinecartPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundSetCommandMinecartPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.command = helper.readString(in); this.doesTrackOutput = in.readBoolean(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); helper.writeString(out, this.command); out.writeBoolean(this.doesTrackOutput); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCreativeModeSlotPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCreativeModeSlotPacket.java index 024179f3..4298ea52 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCreativeModeSlotPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetCreativeModeSlotPacket.java @@ -8,6 +8,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; import lombok.With; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; @@ -16,7 +17,7 @@ import java.io.IOException; @AllArgsConstructor public class ServerboundSetCreativeModeSlotPacket implements MinecraftPacket { private final int slot; - private final @NonNull ItemStack clickedItem; + private final @Nullable ItemStack clickedItem; public ServerboundSetCreativeModeSlotPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { this.slot = in.readShort(); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetJigsawBlockPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetJigsawBlockPacket.java index 5f940998..6b8d8de5 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetJigsawBlockPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetJigsawBlockPacket.java @@ -9,8 +9,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -24,7 +22,7 @@ public class ServerboundSetJigsawBlockPacket implements MinecraftPacket { private final int selectionPriority; private final int placementPriority; - public ServerboundSetJigsawBlockPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundSetJigsawBlockPacket(ByteBuf in, MinecraftCodecHelper helper) { this.position = helper.readPosition(in); this.name = helper.readString(in); this.target = helper.readString(in); @@ -36,7 +34,7 @@ public class ServerboundSetJigsawBlockPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writePosition(out, this.position); helper.writeString(out, this.name); helper.writeString(out, this.target); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetStructureBlockPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetStructureBlockPacket.java index ebe76ad8..411b3985 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetStructureBlockPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetStructureBlockPacket.java @@ -13,8 +13,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -38,7 +36,7 @@ public class ServerboundSetStructureBlockPacket implements MinecraftPacket { private final boolean showAir; private final boolean showBoundingBox; - public ServerboundSetStructureBlockPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundSetStructureBlockPacket(ByteBuf in, MinecraftCodecHelper helper) { this.position = helper.readPosition(in); this.action = UpdateStructureBlockAction.from(helper.readVarInt(in)); this.mode = UpdateStructureBlockMode.from(helper.readVarInt(in)); @@ -58,7 +56,7 @@ public class ServerboundSetStructureBlockPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writePosition(out, this.position); helper.writeVarInt(out, this.action.ordinal()); helper.writeVarInt(out, this.mode.ordinal()); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundAcceptTeleportationPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundAcceptTeleportationPacket.java index 4daf051e..78459753 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundAcceptTeleportationPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundAcceptTeleportationPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundAcceptTeleportationPacket implements MinecraftPacket { private final int id; - public ServerboundAcceptTeleportationPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundAcceptTeleportationPacket(ByteBuf in, MinecraftCodecHelper helper) { this.id = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.id); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundBlockEntityTagQuery.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundBlockEntityTagQuery.java index 269d53e3..3d0d67e6 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundBlockEntityTagQuery.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundBlockEntityTagQuery.java @@ -9,8 +9,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,13 +16,13 @@ public class ServerboundBlockEntityTagQuery implements MinecraftPacket { private final int transactionId; private final @NonNull Vector3i position; - public ServerboundBlockEntityTagQuery(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundBlockEntityTagQuery(ByteBuf in, MinecraftCodecHelper helper) { this.transactionId = helper.readVarInt(in); this.position = helper.readPosition(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.transactionId); helper.writePosition(out, this.position); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundEntityTagQuery.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundEntityTagQuery.java index e1a938cf..fcd24658 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundEntityTagQuery.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundEntityTagQuery.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -16,13 +14,13 @@ public class ServerboundEntityTagQuery implements MinecraftPacket { private final int transactionId; private final int entityId; - public ServerboundEntityTagQuery(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundEntityTagQuery(ByteBuf in, MinecraftCodecHelper helper) { this.transactionId = helper.readVarInt(in); this.entityId = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.transactionId); helper.writeVarInt(out, this.entityId); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundJigsawGeneratePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundJigsawGeneratePacket.java index f117b968..fa0e11f3 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundJigsawGeneratePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundJigsawGeneratePacket.java @@ -9,8 +9,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -19,14 +17,14 @@ public class ServerboundJigsawGeneratePacket implements MinecraftPacket { private final int levels; private final boolean keepJigsaws; - public ServerboundJigsawGeneratePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundJigsawGeneratePacket(ByteBuf in, MinecraftCodecHelper helper) { this.position = helper.readPosition(in); this.levels = helper.readVarInt(in); this.keepJigsaws = in.readBoolean(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writePosition(out, this.position); helper.writeVarInt(out, this.levels); out.writeBoolean(this.keepJigsaws); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundMoveVehiclePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundMoveVehiclePacket.java index 7cbc98f5..4dee0753 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundMoveVehiclePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundMoveVehiclePacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -19,7 +17,7 @@ public class ServerboundMoveVehiclePacket implements MinecraftPacket { private final float yaw; private final float pitch; - public ServerboundMoveVehiclePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundMoveVehiclePacket(ByteBuf in, MinecraftCodecHelper helper) { this.x = in.readDouble(); this.y = in.readDouble(); this.z = in.readDouble(); @@ -28,7 +26,7 @@ public class ServerboundMoveVehiclePacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeDouble(this.x); out.writeDouble(this.y); out.writeDouble(this.z); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundPaddleBoatPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundPaddleBoatPacket.java index 47d8a96e..68cfec92 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundPaddleBoatPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundPaddleBoatPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -16,13 +14,13 @@ public class ServerboundPaddleBoatPacket implements MinecraftPacket { private final boolean rightPaddleTurning; private final boolean leftPaddleTurning; - public ServerboundPaddleBoatPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundPaddleBoatPacket(ByteBuf in, MinecraftCodecHelper helper) { this.rightPaddleTurning = in.readBoolean(); this.leftPaddleTurning = in.readBoolean(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeBoolean(this.rightPaddleTurning); out.writeBoolean(this.leftPaddleTurning); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundPlayerInputPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundPlayerInputPacket.java index 2e89ff5f..478a593b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundPlayerInputPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundPlayerInputPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -21,7 +19,7 @@ public class ServerboundPlayerInputPacket implements MinecraftPacket { private final boolean jump; private final boolean dismount; - public ServerboundPlayerInputPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundPlayerInputPacket(ByteBuf in, MinecraftCodecHelper helper) { this.sideways = in.readFloat(); this.forward = in.readFloat(); @@ -31,7 +29,7 @@ public class ServerboundPlayerInputPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeFloat(this.sideways); out.writeFloat(this.forward); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundSignUpdatePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundSignUpdatePacket.java index c8eaeca7..a23fa4b6 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundSignUpdatePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundSignUpdatePacket.java @@ -8,7 +8,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; import java.util.Arrays; @Data diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundTeleportToEntityPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundTeleportToEntityPacket.java index 221b0d54..a21fb0c1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundTeleportToEntityPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundTeleportToEntityPacket.java @@ -8,7 +8,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; import java.util.UUID; @Data @@ -17,12 +16,12 @@ import java.util.UUID; public class ServerboundTeleportToEntityPacket implements MinecraftPacket { private final @NonNull UUID target; - public ServerboundTeleportToEntityPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundTeleportToEntityPacket(ByteBuf in, MinecraftCodecHelper helper) { this.target = helper.readUUID(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeUUID(out, this.target); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundInteractPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundInteractPacket.java index 8ad77abf..565b3864 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundInteractPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundInteractPacket.java @@ -10,8 +10,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -33,7 +31,7 @@ public class ServerboundInteractPacket implements MinecraftPacket { this(entityId, action, 0, 0, 0, hand, isSneaking); } - public ServerboundInteractPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundInteractPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.action = InteractAction.from(helper.readVarInt(in)); if (this.action == InteractAction.INTERACT_AT) { @@ -55,7 +53,7 @@ public class ServerboundInteractPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); helper.writeVarInt(out, this.action.ordinal()); if (this.action == InteractAction.INTERACT_AT) { diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerPosPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerPosPacket.java index 4137143d..49714a00 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerPosPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerPosPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,7 +16,7 @@ public class ServerboundMovePlayerPosPacket implements MinecraftPacket { private final double y; private final double z; - public ServerboundMovePlayerPosPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundMovePlayerPosPacket(ByteBuf in, MinecraftCodecHelper helper) { this.x = in.readDouble(); this.y = in.readDouble(); this.z = in.readDouble(); @@ -26,7 +24,7 @@ public class ServerboundMovePlayerPosPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeDouble(this.x); out.writeDouble(this.y); out.writeDouble(this.z); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerPosRotPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerPosRotPacket.java index 773b4673..4e11e243 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerPosRotPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerPosRotPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -20,7 +18,7 @@ public class ServerboundMovePlayerPosRotPacket implements MinecraftPacket { private final float yaw; private final float pitch; - public ServerboundMovePlayerPosRotPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundMovePlayerPosRotPacket(ByteBuf in, MinecraftCodecHelper helper) { this.x = in.readDouble(); this.y = in.readDouble(); this.z = in.readDouble(); @@ -30,7 +28,7 @@ public class ServerboundMovePlayerPosRotPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeDouble(this.x); out.writeDouble(this.y); out.writeDouble(this.z); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerRotPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerRotPacket.java index 19414987..fd3e9ff1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerRotPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerRotPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,14 +15,14 @@ public class ServerboundMovePlayerRotPacket implements MinecraftPacket { private final float yaw; private final float pitch; - public ServerboundMovePlayerRotPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundMovePlayerRotPacket(ByteBuf in, MinecraftCodecHelper helper) { this.yaw = in.readFloat(); this.pitch = in.readFloat(); this.onGround = in.readBoolean(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeFloat(this.yaw); out.writeFloat(this.pitch); out.writeBoolean(this.onGround); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerStatusOnlyPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerStatusOnlyPacket.java index 997f5a51..5002fe60 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerStatusOnlyPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundMovePlayerStatusOnlyPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundMovePlayerStatusOnlyPacket implements MinecraftPacket { private final boolean onGround; - public ServerboundMovePlayerStatusOnlyPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundMovePlayerStatusOnlyPacket(ByteBuf in, MinecraftCodecHelper helper) { this.onGround = in.readBoolean(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeBoolean(this.onGround); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerAbilitiesPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerAbilitiesPacket.java index c6744214..beb31605 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerAbilitiesPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerAbilitiesPacket.java @@ -7,8 +7,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -17,13 +15,13 @@ public class ServerboundPlayerAbilitiesPacket implements MinecraftPacket { private final boolean flying; - public ServerboundPlayerAbilitiesPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundPlayerAbilitiesPacket(ByteBuf in, MinecraftCodecHelper helper) { byte flags = in.readByte(); this.flying = (flags & FLAG_FLYING) > 0; } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { int flags = 0; if (this.flying) { diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerActionPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerActionPacket.java index af24aabd..ddc77393 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerActionPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerActionPacket.java @@ -11,8 +11,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -22,7 +20,7 @@ public class ServerboundPlayerActionPacket implements MinecraftPacket { private final @NonNull Direction face; private final int sequence; - public ServerboundPlayerActionPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundPlayerActionPacket(ByteBuf in, MinecraftCodecHelper helper) { this.action = PlayerAction.from(helper.readVarInt(in)); this.position = helper.readPosition(in); this.face = Direction.VALUES[in.readUnsignedByte()]; @@ -30,7 +28,7 @@ public class ServerboundPlayerActionPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.action.ordinal()); helper.writePosition(out, this.position); out.writeByte(this.face.ordinal()); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerCommandPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerCommandPacket.java index 8df66211..ea76f3df 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerCommandPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerCommandPacket.java @@ -9,8 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -23,14 +21,14 @@ public class ServerboundPlayerCommandPacket implements MinecraftPacket { this(entityId, state, 0); } - public ServerboundPlayerCommandPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundPlayerCommandPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entityId = helper.readVarInt(in); this.state = PlayerState.from(helper.readVarInt(in)); this.jumpBoost = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.entityId); helper.writeVarInt(out, this.state.ordinal()); helper.writeVarInt(out, this.jumpBoost); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundSetCarriedItemPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundSetCarriedItemPacket.java index 302ec208..c8fd49af 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundSetCarriedItemPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundSetCarriedItemPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundSetCarriedItemPacket implements MinecraftPacket { private final int slot; - public ServerboundSetCarriedItemPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundSetCarriedItemPacket(ByteBuf in, MinecraftCodecHelper helper) { this.slot = in.readShort(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeShort(this.slot); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundSwingPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundSwingPacket.java index fd0668a4..ffb15168 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundSwingPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundSwingPacket.java @@ -9,20 +9,18 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundSwingPacket implements MinecraftPacket { private final @NonNull Hand hand; - public ServerboundSwingPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundSwingPacket(ByteBuf in, MinecraftCodecHelper helper) { this.hand = Hand.from(helper.readVarInt(in)); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.hand.ordinal()); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemOnPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemOnPacket.java index e138c840..1e05a05c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemOnPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemOnPacket.java @@ -11,8 +11,6 @@ import lombok.NonNull; import lombok.With; import org.cloudburstmc.math.vector.Vector3i; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -26,7 +24,7 @@ public class ServerboundUseItemOnPacket implements MinecraftPacket { private final boolean insideBlock; private final int sequence; - public ServerboundUseItemOnPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundUseItemOnPacket(ByteBuf in, MinecraftCodecHelper helper) { this.hand = Hand.from(helper.readVarInt(in)); this.position = helper.readPosition(in); this.face = helper.readDirection(in); @@ -38,7 +36,7 @@ public class ServerboundUseItemOnPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.hand.ordinal()); helper.writePosition(out, this.position); helper.writeDirection(out, this.face); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemPacket.java index 914e285d..87e6bea5 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemPacket.java @@ -9,8 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,13 +16,13 @@ public class ServerboundUseItemPacket implements MinecraftPacket { private final @NonNull Hand hand; private final int sequence; - public ServerboundUseItemPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundUseItemPacket(ByteBuf in, MinecraftCodecHelper helper) { this.hand = Hand.from(helper.readVarInt(in)); this.sequence = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.hand.ordinal()); helper.writeVarInt(out, this.sequence); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundCustomQueryPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundCustomQueryPacket.java index 7d123428..0aea50ba 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundCustomQueryPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundCustomQueryPacket.java @@ -8,8 +8,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -18,14 +16,14 @@ public class ClientboundCustomQueryPacket implements MinecraftPacket { private final @NonNull String channel; private final byte @NonNull[] data; - public ClientboundCustomQueryPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundCustomQueryPacket(ByteBuf in, MinecraftCodecHelper helper) { this.messageId = helper.readVarInt(in); this.channel = helper.readString(in); this.data = helper.readByteArray(in, ByteBuf::readableBytes); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.messageId); helper.writeString(out, this.channel); out.writeBytes(this.data); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundGameProfilePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundGameProfilePacket.java index 976fd6e3..6aa020b5 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundGameProfilePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundGameProfilePacket.java @@ -9,7 +9,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -19,7 +18,7 @@ import java.util.List; public class ClientboundGameProfilePacket implements MinecraftPacket { private final @NonNull GameProfile profile; - public ClientboundGameProfilePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundGameProfilePacket(ByteBuf in, MinecraftCodecHelper helper) { GameProfile profile = new GameProfile(helper.readUUID(in), helper.readString(in)); int properties = helper.readVarInt(in); List propertyList = new ArrayList<>(); @@ -39,7 +38,7 @@ public class ClientboundGameProfilePacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeUUID(out, this.profile.getId()); helper.writeString(out, this.profile.getName()); helper.writeVarInt(out, this.profile.getProperties().size()); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundHelloPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundHelloPacket.java index 193b182f..f3b7f6ad 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundHelloPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundHelloPacket.java @@ -20,7 +20,7 @@ import java.security.spec.X509EncodedKeySpec; public class ClientboundHelloPacket implements MinecraftPacket { private final @NonNull String serverId; private final @NonNull PublicKey publicKey; - private final @NonNull byte[] challenge; + private final byte @NonNull [] challenge; public ClientboundHelloPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { this.serverId = helper.readString(in); @@ -35,7 +35,7 @@ public class ClientboundHelloPacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeString(out, this.serverId); byte[] encoded = this.publicKey.getEncoded(); helper.writeByteArray(out, encoded); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundLoginCompressionPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundLoginCompressionPacket.java index d783623d..07160e1f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundLoginCompressionPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundLoginCompressionPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundLoginCompressionPacket implements MinecraftPacket { private final int threshold; - public ClientboundLoginCompressionPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundLoginCompressionPacket(ByteBuf in, MinecraftCodecHelper helper) { this.threshold = helper.readVarInt(in); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(out, this.threshold); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundLoginDisconnectPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundLoginDisconnectPacket.java index 2413d24e..60f7c8e8 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundLoginDisconnectPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundLoginDisconnectPacket.java @@ -10,8 +10,6 @@ import lombok.NonNull; import lombok.With; import net.kyori.adventure.text.Component; -import java.io.IOException; - @Data @With @AllArgsConstructor @@ -25,13 +23,13 @@ public class ClientboundLoginDisconnectPacket implements MinecraftPacket { this(DefaultComponentSerializer.get().deserialize(text)); } - public ClientboundLoginDisconnectPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundLoginDisconnectPacket(ByteBuf in, MinecraftCodecHelper helper) { // uses the old json serialization rather than the 1.20.3 NBT serialization this.reason = DefaultComponentSerializer.get().deserialize(helper.readString(in, MAX_COMPONENT_STRING_LENGTH)); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeString(out, DefaultComponentSerializer.get().serialize(reason)); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryAnswerPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryAnswerPacket.java index 44c76f9f..f5c3ec1f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryAnswerPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryAnswerPacket.java @@ -6,7 +6,7 @@ import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; @Data @With diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java index 75a1c6e5..ad24c4e7 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java @@ -8,7 +8,6 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; import java.util.UUID; @Data @@ -18,7 +17,7 @@ public class ServerboundHelloPacket implements MinecraftPacket { private final @NonNull String username; private final @NonNull UUID profileId; - public ServerboundHelloPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundHelloPacket(ByteBuf in, MinecraftCodecHelper helper) { this.username = helper.readString(in); this.profileId = helper.readUUID(in); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundPongResponsePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundPongResponsePacket.java index 24d93173..9597cd4f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundPongResponsePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundPongResponsePacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ClientboundPongResponsePacket implements MinecraftPacket { private final long pingTime; - public ClientboundPongResponsePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundPongResponsePacket(ByteBuf in, MinecraftCodecHelper helper) { this.pingTime = in.readLong(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeLong(this.pingTime); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacket.java index 6a501ecf..e8a4c8ba 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacket.java @@ -19,7 +19,6 @@ import lombok.NonNull; import lombok.With; import net.kyori.adventure.text.Component; -import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -34,7 +33,7 @@ public class ClientboundStatusResponsePacket implements MinecraftPacket { private final @NonNull ServerStatusInfo info; - public ClientboundStatusResponsePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ClientboundStatusResponsePacket(ByteBuf in, MinecraftCodecHelper helper) { JsonObject obj = new Gson().fromJson(helper.readString(in), JsonObject.class); JsonElement desc = obj.get("description"); Component description = DefaultComponentSerializer.get().serializer().fromJson(desc, Component.class); @@ -66,7 +65,7 @@ public class ClientboundStatusResponsePacket implements MinecraftPacket { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { JsonObject obj = new JsonObject(); JsonObject ver = new JsonObject(); ver.addProperty("name", this.info.getVersionInfo().getVersionName()); @@ -74,7 +73,7 @@ public class ClientboundStatusResponsePacket implements MinecraftPacket { JsonObject plrs = new JsonObject(); plrs.addProperty("max", this.info.getPlayerInfo().getMaxPlayers()); plrs.addProperty("online", this.info.getPlayerInfo().getOnlinePlayers()); - if (this.info.getPlayerInfo().getPlayers().size() > 0) { + if (!this.info.getPlayerInfo().getPlayers().isEmpty()) { JsonArray array = new JsonArray(); for (GameProfile profile : this.info.getPlayerInfo().getPlayers()) { JsonObject o = new JsonObject(); @@ -97,11 +96,6 @@ public class ClientboundStatusResponsePacket implements MinecraftPacket { helper.writeString(out, obj.toString()); } - @Override - public boolean isPriority() { - return false; - } - private byte[] stringToIcon(String str) { if (str.startsWith("data:image/png;base64,")) { str = str.substring("data:image/png;base64,".length()); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/status/serverbound/ServerboundPingRequestPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/status/serverbound/ServerboundPingRequestPacket.java index 1da7f0d5..7fa67d2c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/status/serverbound/ServerboundPingRequestPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/status/serverbound/ServerboundPingRequestPacket.java @@ -7,20 +7,18 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.With; -import java.io.IOException; - @Data @With @AllArgsConstructor public class ServerboundPingRequestPacket implements MinecraftPacket { private final long pingTime; - public ServerboundPingRequestPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundPingRequestPacket(ByteBuf in, MinecraftCodecHelper helper) { this.pingTime = in.readLong(); } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeLong(this.pingTime); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/status/serverbound/ServerboundStatusRequestPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/status/serverbound/ServerboundStatusRequestPacket.java index 958ff9fa..2bbaf66a 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/status/serverbound/ServerboundStatusRequestPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/status/serverbound/ServerboundStatusRequestPacket.java @@ -6,16 +6,14 @@ import io.netty.buffer.ByteBuf; import lombok.Data; import lombok.NoArgsConstructor; -import java.io.IOException; - @Data @NoArgsConstructor public class ServerboundStatusRequestPacket implements MinecraftPacket { - public ServerboundStatusRequestPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + public ServerboundStatusRequestPacket(ByteBuf in, MinecraftCodecHelper helper) { } @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { } } diff --git a/src/main/java/com/github/steveice10/packetlib/ProxyInfo.java b/src/main/java/com/github/steveice10/packetlib/ProxyInfo.java index 90e6544f..44288827 100644 --- a/src/main/java/com/github/steveice10/packetlib/ProxyInfo.java +++ b/src/main/java/com/github/steveice10/packetlib/ProxyInfo.java @@ -6,8 +6,8 @@ import java.net.SocketAddress; * Information describing a network proxy. */ public class ProxyInfo { - private Type type; - private SocketAddress address; + private final Type type; + private final SocketAddress address; private boolean authenticated; private String username; private String password; diff --git a/src/main/java/com/github/steveice10/packetlib/Session.java b/src/main/java/com/github/steveice10/packetlib/Session.java index e1d1163d..2822ef05 100644 --- a/src/main/java/com/github/steveice10/packetlib/Session.java +++ b/src/main/java/com/github/steveice10/packetlib/Session.java @@ -7,7 +7,7 @@ import com.github.steveice10.packetlib.event.session.SessionListener; import com.github.steveice10.packetlib.packet.Packet; import com.github.steveice10.packetlib.packet.PacketProtocol; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.net.SocketAddress; import java.util.List; @@ -21,49 +21,49 @@ public interface Session { /** * Connects this session to its host and port. */ - public void connect(); + void connect(); /** * Connects this session to its host and port. * * @param wait Whether to wait for the connection to be established before returning. */ - public void connect(boolean wait); + void connect(boolean wait); /** * Gets the host the session is connected to. * * @return The connected host. */ - public String getHost(); + String getHost(); /** * Gets the port the session is connected to. * * @return The connected port. */ - public int getPort(); + int getPort(); /** * Gets the local address of the session. * * @return The local address, or null if the session is not connected. */ - public SocketAddress getLocalAddress(); + SocketAddress getLocalAddress(); /** * Gets the remote address of the session. * * @return The remote address, or null if the session is not connected. */ - public SocketAddress getRemoteAddress(); + SocketAddress getRemoteAddress(); /** * Gets the packet protocol of the session. * * @return The session's packet protocol. */ - public PacketProtocol getPacketProtocol(); + PacketProtocol getPacketProtocol(); /** * Gets the session's {@link PacketCodecHelper}. @@ -78,7 +78,7 @@ public interface Session { * * @return This session's flags. */ - public Map getFlags(); + Map getFlags(); /** * Checks whether this session has a flag set. If this session belongs to a server, @@ -87,7 +87,7 @@ public interface Session { * @param key Key of the flag to check for. * @return Whether this session has a flag set. */ - public boolean hasFlag(String key); + boolean hasFlag(String key); /** * Gets the value of the given flag as an instance of the given type. If this @@ -99,7 +99,7 @@ public interface Session { * @return Value of the flag. * @throws IllegalStateException If the flag's value isn't of the required type. */ - public T getFlag(String key); + T getFlag(String key); /** * Gets the value of the given flag as an instance of the given type. If this @@ -112,7 +112,7 @@ public interface Session { * @return Value of the flag. * @throws IllegalStateException If the flag's value isn't of the required type. */ - public T getFlag(String key, T def); + T getFlag(String key, T def); /** * Sets the value of a flag. This does not change a server's flags if this session @@ -121,28 +121,28 @@ public interface Session { * @param key Key of the flag. * @param value Value to set the flag to. */ - public void setFlag(String key, Object value); + void setFlag(String key, Object value); /** * Gets the listeners listening on this session. * * @return This session's listeners. */ - public List getListeners(); + List getListeners(); /** * Adds a listener to this session. * * @param listener Listener to add. */ - public void addListener(SessionListener listener); + void addListener(SessionListener listener); /** * Removes a listener from this session. * * @param listener Listener to remove. */ - public void removeListener(SessionListener listener); + void removeListener(SessionListener listener); /** * Calls an event on the listeners of this session. @@ -192,56 +192,56 @@ public interface Session { * * @return The session's connect timeout. */ - public int getConnectTimeout(); + int getConnectTimeout(); /** * Sets the connect timeout for this session in seconds. * * @param timeout Connect timeout to set. */ - public void setConnectTimeout(int timeout); + void setConnectTimeout(int timeout); /** * Gets the read timeout for this session in seconds. * * @return The session's read timeout. */ - public int getReadTimeout(); + int getReadTimeout(); /** * Sets the read timeout for this session in seconds. * * @param timeout Read timeout to set. */ - public void setReadTimeout(int timeout); + void setReadTimeout(int timeout); /** * Gets the write timeout for this session in seconds. * * @return The session's write timeout. */ - public int getWriteTimeout(); + int getWriteTimeout(); /** * Sets the write timeout for this session in seconds. * * @param timeout Write timeout to set. */ - public void setWriteTimeout(int timeout); + void setWriteTimeout(int timeout); /** * Returns true if the session is connected. * * @return True if the session is connected. */ - public boolean isConnected(); + boolean isConnected(); /** * Sends a packet. * * @param packet Packet to send. */ - public void send(Packet packet); + void send(Packet packet); /** * Disconnects the session. diff --git a/src/main/java/com/github/steveice10/packetlib/crypt/AESEncryption.java b/src/main/java/com/github/steveice10/packetlib/crypt/AESEncryption.java index 7dc26a90..75361fd3 100644 --- a/src/main/java/com/github/steveice10/packetlib/crypt/AESEncryption.java +++ b/src/main/java/com/github/steveice10/packetlib/crypt/AESEncryption.java @@ -9,8 +9,8 @@ import java.security.Key; * An encryption implementation using "AES/CFB8/NoPadding" encryption. */ public class AESEncryption implements PacketEncryption { - private Cipher inCipher; - private Cipher outCipher; + private final Cipher inCipher; + private final Cipher outCipher; /** * Creates a new AESEncryption instance. diff --git a/src/main/java/com/github/steveice10/packetlib/crypt/PacketEncryption.java b/src/main/java/com/github/steveice10/packetlib/crypt/PacketEncryption.java index 371ca240..f185c34c 100644 --- a/src/main/java/com/github/steveice10/packetlib/crypt/PacketEncryption.java +++ b/src/main/java/com/github/steveice10/packetlib/crypt/PacketEncryption.java @@ -10,7 +10,7 @@ public interface PacketEncryption { * @param length Length of the data being decrypted. * @return The output size from decrypting. */ - public int getDecryptOutputSize(int length); + int getDecryptOutputSize(int length); /** * Gets the output size from encrypting. @@ -18,7 +18,7 @@ public interface PacketEncryption { * @param length Length of the data being encrypted. * @return The output size from encrypting. */ - public int getEncryptOutputSize(int length); + int getEncryptOutputSize(int length); /** * Decrypts the given data. @@ -31,7 +31,7 @@ public interface PacketEncryption { * @return The number of bytes stored in the output array. * @throws Exception If an error occurs. */ - public int decrypt(byte input[], int inputOffset, int inputLength, byte output[], int outputOffset) throws Exception; + int decrypt(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws Exception; /** * Encrypts the given data. @@ -44,5 +44,5 @@ public interface PacketEncryption { * @return The number of bytes stored in the output array. * @throws Exception If an error occurs. */ - public int encrypt(byte input[], int inputOffset, int inputLength, byte output[], int outputOffset) throws Exception; + int encrypt(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws Exception; } diff --git a/src/main/java/com/github/steveice10/packetlib/event/server/ServerBoundEvent.java b/src/main/java/com/github/steveice10/packetlib/event/server/ServerBoundEvent.java index 54cb07a8..52736e67 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/server/ServerBoundEvent.java +++ b/src/main/java/com/github/steveice10/packetlib/event/server/ServerBoundEvent.java @@ -6,7 +6,7 @@ import com.github.steveice10.packetlib.Server; * Called when the server is bound to its host and port. */ public class ServerBoundEvent implements ServerEvent { - private Server server; + private final Server server; /** * Creates a new ServerBoundEvent instance. diff --git a/src/main/java/com/github/steveice10/packetlib/event/server/ServerClosedEvent.java b/src/main/java/com/github/steveice10/packetlib/event/server/ServerClosedEvent.java index c6251c2f..65f7037f 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/server/ServerClosedEvent.java +++ b/src/main/java/com/github/steveice10/packetlib/event/server/ServerClosedEvent.java @@ -6,7 +6,7 @@ import com.github.steveice10.packetlib.Server; * Called when the server is closed. */ public class ServerClosedEvent implements ServerEvent { - private Server server; + private final Server server; /** * Creates a new ServerClosedEvent instance. diff --git a/src/main/java/com/github/steveice10/packetlib/event/server/ServerClosingEvent.java b/src/main/java/com/github/steveice10/packetlib/event/server/ServerClosingEvent.java index ebcb6d14..3e44ad46 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/server/ServerClosingEvent.java +++ b/src/main/java/com/github/steveice10/packetlib/event/server/ServerClosingEvent.java @@ -6,7 +6,7 @@ import com.github.steveice10.packetlib.Server; * Called when the server is about to close. */ public class ServerClosingEvent implements ServerEvent { - private Server server; + private final Server server; /** * Creates a new ServerClosingEvent instance. diff --git a/src/main/java/com/github/steveice10/packetlib/event/server/ServerEvent.java b/src/main/java/com/github/steveice10/packetlib/event/server/ServerEvent.java index 2037d5bb..5387d86c 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/server/ServerEvent.java +++ b/src/main/java/com/github/steveice10/packetlib/event/server/ServerEvent.java @@ -9,5 +9,5 @@ public interface ServerEvent { * * @param listener Listener to call the event on. */ - public void call(ServerListener listener); + void call(ServerListener listener); } diff --git a/src/main/java/com/github/steveice10/packetlib/event/server/ServerListener.java b/src/main/java/com/github/steveice10/packetlib/event/server/ServerListener.java index 6c32331f..dbe1ac25 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/server/ServerListener.java +++ b/src/main/java/com/github/steveice10/packetlib/event/server/ServerListener.java @@ -9,33 +9,33 @@ public interface ServerListener { * * @param event Data relating to the event. */ - public void serverBound(ServerBoundEvent event); + void serverBound(ServerBoundEvent event); /** * Called when a server is about to close. * * @param event Data relating to the event. */ - public void serverClosing(ServerClosingEvent event); + void serverClosing(ServerClosingEvent event); /** * Called when a server is closed. * * @param event Data relating to the event. */ - public void serverClosed(ServerClosedEvent event); + void serverClosed(ServerClosedEvent event); /** * Called when a session is added to the server. * * @param event Data relating to the event. */ - public void sessionAdded(SessionAddedEvent event); + void sessionAdded(SessionAddedEvent event); /** * Called when a session is removed and disconnected from the server. * * @param event Data relating to the event. */ - public void sessionRemoved(SessionRemovedEvent event); + void sessionRemoved(SessionRemovedEvent event); } diff --git a/src/main/java/com/github/steveice10/packetlib/event/server/SessionAddedEvent.java b/src/main/java/com/github/steveice10/packetlib/event/server/SessionAddedEvent.java index 3adb49c0..a328c173 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/server/SessionAddedEvent.java +++ b/src/main/java/com/github/steveice10/packetlib/event/server/SessionAddedEvent.java @@ -7,8 +7,8 @@ import com.github.steveice10.packetlib.Session; * Called when a session is added to the server. */ public class SessionAddedEvent implements ServerEvent { - private Server server; - private Session session; + private final Server server; + private final Session session; /** * Creates a new SessionAddedEvent instance. diff --git a/src/main/java/com/github/steveice10/packetlib/event/server/SessionRemovedEvent.java b/src/main/java/com/github/steveice10/packetlib/event/server/SessionRemovedEvent.java index 8bb49bc0..ae80c572 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/server/SessionRemovedEvent.java +++ b/src/main/java/com/github/steveice10/packetlib/event/server/SessionRemovedEvent.java @@ -7,8 +7,8 @@ import com.github.steveice10.packetlib.Session; * Called when a session is removed and disconnected from the server. */ public class SessionRemovedEvent implements ServerEvent { - private Server server; - private Session session; + private final Server server; + private final Session session; /** * Creates a new SessionRemovedEvent instance. diff --git a/src/main/java/com/github/steveice10/packetlib/event/session/ConnectedEvent.java b/src/main/java/com/github/steveice10/packetlib/event/session/ConnectedEvent.java index 1e312e70..37933357 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/session/ConnectedEvent.java +++ b/src/main/java/com/github/steveice10/packetlib/event/session/ConnectedEvent.java @@ -6,7 +6,7 @@ import com.github.steveice10.packetlib.Session; * Called when the session connects. */ public class ConnectedEvent implements SessionEvent { - private Session session; + private final Session session; /** * Creates a new ConnectedEvent instance. diff --git a/src/main/java/com/github/steveice10/packetlib/event/session/PacketErrorEvent.java b/src/main/java/com/github/steveice10/packetlib/event/session/PacketErrorEvent.java index 735ca58b..e5f5cecc 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/session/PacketErrorEvent.java +++ b/src/main/java/com/github/steveice10/packetlib/event/session/PacketErrorEvent.java @@ -6,8 +6,8 @@ import com.github.steveice10.packetlib.Session; * Called when a session encounters an error while reading or writing packet data. */ public class PacketErrorEvent implements SessionEvent { - private Session session; - private Throwable cause; + private final Session session; + private final Throwable cause; private boolean suppress = false; /** @@ -42,7 +42,6 @@ public class PacketErrorEvent implements SessionEvent { /** * Gets whether the error should be suppressed. If the error is not suppressed, * it will be passed on through internal error handling and disconnect the session. - * * The default value is false. * * @return Whether the error should be suppressed. diff --git a/src/main/java/com/github/steveice10/packetlib/event/session/PacketSendingEvent.java b/src/main/java/com/github/steveice10/packetlib/event/session/PacketSendingEvent.java index c5814a4f..469352ca 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/session/PacketSendingEvent.java +++ b/src/main/java/com/github/steveice10/packetlib/event/session/PacketSendingEvent.java @@ -7,7 +7,7 @@ import com.github.steveice10.packetlib.packet.Packet; * Called when the session is sending a packet. */ public class PacketSendingEvent implements SessionEvent { - private Session session; + private final Session session; private Packet packet; private boolean cancelled = false; diff --git a/src/main/java/com/github/steveice10/packetlib/event/session/SessionEvent.java b/src/main/java/com/github/steveice10/packetlib/event/session/SessionEvent.java index bcd2b727..584e30da 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/session/SessionEvent.java +++ b/src/main/java/com/github/steveice10/packetlib/event/session/SessionEvent.java @@ -9,5 +9,5 @@ public interface SessionEvent { * * @param listener Listener to call the event on. */ - public void call(SessionListener listener); + void call(SessionListener listener); } diff --git a/src/main/java/com/github/steveice10/packetlib/event/session/SessionListener.java b/src/main/java/com/github/steveice10/packetlib/event/session/SessionListener.java index 6ffd3f0c..2e522e52 100644 --- a/src/main/java/com/github/steveice10/packetlib/event/session/SessionListener.java +++ b/src/main/java/com/github/steveice10/packetlib/event/session/SessionListener.java @@ -19,7 +19,7 @@ public interface SessionListener { * * @param event Data relating to the event. */ - public void packetSending(PacketSendingEvent event); + void packetSending(PacketSendingEvent event); /** * Called when a session sends a packet. @@ -33,26 +33,26 @@ public interface SessionListener { * * @param event Data relating to the event. */ - public void packetError(PacketErrorEvent event); + void packetError(PacketErrorEvent event); /** * Called when a session connects. * * @param event Data relating to the event. */ - public void connected(ConnectedEvent event); + void connected(ConnectedEvent event); /** * Called when a session is about to disconnect. * * @param event Data relating to the event. */ - public void disconnecting(DisconnectingEvent event); + void disconnecting(DisconnectingEvent event); /** * Called when a session is disconnected. * * @param event Data relating to the event. */ - public void disconnected(DisconnectedEvent event); + void disconnected(DisconnectedEvent event); } diff --git a/src/main/java/com/github/steveice10/packetlib/packet/DefaultPacketHeader.java b/src/main/java/com/github/steveice10/packetlib/packet/DefaultPacketHeader.java index f7218680..b918d209 100644 --- a/src/main/java/com/github/steveice10/packetlib/packet/DefaultPacketHeader.java +++ b/src/main/java/com/github/steveice10/packetlib/packet/DefaultPacketHeader.java @@ -3,8 +3,6 @@ package com.github.steveice10.packetlib.packet; import com.github.steveice10.packetlib.codec.PacketCodecHelper; import io.netty.buffer.ByteBuf; -import java.io.IOException; - /** * The default packet header, using a varint packet length and id. */ @@ -35,22 +33,22 @@ public class DefaultPacketHeader implements PacketHeader { } @Override - public int readLength(ByteBuf buf, PacketCodecHelper codecHelper, int available) throws IOException { + public int readLength(ByteBuf buf, PacketCodecHelper codecHelper, int available) { return codecHelper.readVarInt(buf); } @Override - public void writeLength(ByteBuf buf, PacketCodecHelper codecHelper, int length) throws IOException { + public void writeLength(ByteBuf buf, PacketCodecHelper codecHelper, int length) { codecHelper.writeVarInt(buf, length); } @Override - public int readPacketId(ByteBuf buf, PacketCodecHelper codecHelper) throws IOException { + public int readPacketId(ByteBuf buf, PacketCodecHelper codecHelper) { return codecHelper.readVarInt(buf); } @Override - public void writePacketId(ByteBuf buf, PacketCodecHelper codecHelper, int packetId) throws IOException { + public void writePacketId(ByteBuf buf, PacketCodecHelper codecHelper, int packetId) { codecHelper.writeVarInt(buf, packetId); } } diff --git a/src/main/java/com/github/steveice10/packetlib/packet/PacketHeader.java b/src/main/java/com/github/steveice10/packetlib/packet/PacketHeader.java index c2f51144..99eeb266 100644 --- a/src/main/java/com/github/steveice10/packetlib/packet/PacketHeader.java +++ b/src/main/java/com/github/steveice10/packetlib/packet/PacketHeader.java @@ -3,8 +3,6 @@ package com.github.steveice10.packetlib.packet; import com.github.steveice10.packetlib.codec.PacketCodecHelper; import io.netty.buffer.ByteBuf; -import java.io.IOException; - /** * The header of a protocol's packets. */ @@ -14,14 +12,14 @@ public interface PacketHeader { * * @return Whether the header's length value can vary in size. */ - public boolean isLengthVariable(); + boolean isLengthVariable(); /** * Gets the size of the header's length value. * * @return The length value's size. */ - public int getLengthSize(); + int getLengthSize(); /** * Gets the size of the header's length value. @@ -29,7 +27,7 @@ public interface PacketHeader { * @param length Length value to get the size of. * @return The length value's size. */ - public int getLengthSize(int length); + int getLengthSize(int length); /** * Reads the length of a packet from the given input. @@ -38,9 +36,8 @@ public interface PacketHeader { * @param codecHelper The codec helper. * @param available Number of packet bytes available after the length. * @return The resulting packet length. - * @throws java.io.IOException If an I/O error occurs. */ - public int readLength(ByteBuf buf, PacketCodecHelper codecHelper, int available) throws IOException; + int readLength(ByteBuf buf, PacketCodecHelper codecHelper, int available); /** * Writes the length of a packet to the given output. @@ -48,9 +45,8 @@ public interface PacketHeader { * @param buf Buffer to write to. * @param codecHelper The codec helper. * @param length Length to write. - * @throws java.io.IOException If an I/O error occurs. */ - public void writeLength(ByteBuf buf, PacketCodecHelper codecHelper, int length) throws IOException; + void writeLength(ByteBuf buf, PacketCodecHelper codecHelper, int length); /** * Reads the ID of a packet from the given input. @@ -58,9 +54,8 @@ public interface PacketHeader { * @param buf Buffer to read from. * @param codecHelper The codec helper. * @return The resulting packet ID, or -1 if the packet should not be read yet. - * @throws java.io.IOException If an I/O error occurs. */ - public int readPacketId(ByteBuf buf, PacketCodecHelper codecHelper) throws IOException; + int readPacketId(ByteBuf buf, PacketCodecHelper codecHelper); /** * Writes the ID of a packet to the given output. @@ -68,7 +63,6 @@ public interface PacketHeader { * @param buf Buffer to write to. * @param codecHelper The codec helper. * @param packetId Packet ID to write. - * @throws java.io.IOException If an I/O error occurs. */ - public void writePacketId(ByteBuf buf, PacketCodecHelper codecHelper, int packetId) throws IOException; + void writePacketId(ByteBuf buf, PacketCodecHelper codecHelper, int packetId); } diff --git a/src/main/java/com/github/steveice10/packetlib/packet/PacketProtocol.java b/src/main/java/com/github/steveice10/packetlib/packet/PacketProtocol.java index 131f0d0e..a17db1a0 100644 --- a/src/main/java/com/github/steveice10/packetlib/packet/PacketProtocol.java +++ b/src/main/java/com/github/steveice10/packetlib/packet/PacketProtocol.java @@ -10,7 +10,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.io.IOException; -import java.util.HashMap; import java.util.IdentityHashMap; import java.util.Map; @@ -183,8 +182,8 @@ public abstract class PacketProtocol { * @throws IllegalArgumentException If the packet is not registered. */ public int getClientboundId(Packet packet) { - if (packet instanceof BufferedPacket) { - return getClientboundId(((BufferedPacket) packet).getPacketClass()); + if (packet instanceof BufferedPacket bufferedPacket) { + return getClientboundId(bufferedPacket.getPacketClass()); } return getClientboundId(packet.getClass()); @@ -234,7 +233,7 @@ public abstract class PacketProtocol { */ public int getServerboundId(Class packetClass) { Integer packetId = this.serverboundIds.get(packetClass); - if(packetId == null) { + if (packetId == null) { throw new IllegalArgumentException("Unregistered serverbound packet class: " + packetClass.getName()); } @@ -249,8 +248,8 @@ public abstract class PacketProtocol { * @throws IllegalArgumentException If the packet is not registered. */ public int getServerboundId(Packet packet) { - if (packet instanceof BufferedPacket) { - return getServerboundId(((BufferedPacket) packet).getPacketClass()); + if (packet instanceof BufferedPacket bufferedPacket) { + return getServerboundId(bufferedPacket.getPacketClass()); } return getServerboundId(packet.getClass()); diff --git a/src/main/java/com/github/steveice10/packetlib/tcp/TcpBundlerUnpacker.java b/src/main/java/com/github/steveice10/packetlib/tcp/TcpBundlerUnpacker.java index 0a4602b0..8420e981 100644 --- a/src/main/java/com/github/steveice10/packetlib/tcp/TcpBundlerUnpacker.java +++ b/src/main/java/com/github/steveice10/packetlib/tcp/TcpBundlerUnpacker.java @@ -13,7 +13,7 @@ public class TcpBundlerUnpacker extends MessageToMessageDecoder private List currentPackets; @Override - protected void decode(ChannelHandlerContext ctx, MinecraftPacket packet, List out) throws Exception { + protected void decode(ChannelHandlerContext ctx, MinecraftPacket packet, List out) { if (currentPackets != null) { if (packet.getClass() == ClientboundDelimiterPacket.class) { out.add(new ClientboundBundlePacket(currentPackets)); diff --git a/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java b/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java index 22c07fac..6044761b 100644 --- a/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java +++ b/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java @@ -7,14 +7,6 @@ import com.github.steveice10.packetlib.helper.TransportHelper; import com.github.steveice10.packetlib.packet.PacketProtocol; import io.netty.bootstrap.Bootstrap; import io.netty.buffer.ByteBuf; -import io.netty.channel.AddressedEnvelope; -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOption; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.EventLoopGroup; import io.netty.channel.epoll.EpollDatagramChannel; import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.epoll.EpollSocketChannel; @@ -103,7 +95,7 @@ public class TcpClientSession extends TcpSession { try { final Bootstrap bootstrap = new Bootstrap(); bootstrap.channel(CHANNEL_CLASS); - bootstrap.handler(new ChannelInitializer() { + bootstrap.handler(new ChannelInitializer<>() { @Override public void initChannel(Channel channel) { PacketProtocol protocol = getPacketProtocol(); @@ -171,12 +163,10 @@ public class TcpClientSession extends TcpSession { } if(getFlag(BuiltinFlags.ATTEMPT_SRV_RESOLVE, true) && (!this.host.matches(IP_REGEX) && !this.host.equalsIgnoreCase("localhost"))) { - DnsNameResolver resolver = null; AddressedEnvelope envelope = null; - try { - resolver = new DnsNameResolverBuilder(EVENT_LOOP_GROUP.next()) - .channelType(DATAGRAM_CHANNEL_CLASS) - .build(); + try (DnsNameResolver resolver = new DnsNameResolverBuilder(EVENT_LOOP_GROUP.next()) + .channelType(DATAGRAM_CHANNEL_CLASS) + .build()) { envelope = resolver.query(new DefaultDnsQuestion(name, DnsRecordType.SRV)).get(); DnsResponse response = envelope.content(); @@ -192,7 +182,7 @@ public class TcpClientSession extends TcpSession { host = host.substring(0, host.length() - 1); } - if(debug) { + if (debug) { System.out.println("[PacketLib] Found SRV record containing \"" + host + ":" + port + "\"."); } @@ -204,7 +194,7 @@ public class TcpClientSession extends TcpSession { } else if (debug) { System.out.println("[PacketLib] No SRV record found."); } - } catch(Exception e) { + } catch (Exception e) { if (debug) { System.out.println("[PacketLib] Failed to resolve SRV record."); e.printStackTrace(); @@ -214,9 +204,6 @@ public class TcpClientSession extends TcpSession { envelope.release(); } - if (resolver != null) { - resolver.close(); - } } } else if(debug) { System.out.println("[PacketLib] Not resolving SRV record for " + this.host); @@ -240,33 +227,29 @@ public class TcpClientSession extends TcpSession { private void addProxy(ChannelPipeline pipeline) { if(proxy != null) { - switch(proxy.getType()) { - case HTTP: + switch (proxy.getType()) { + case HTTP -> { if (proxy.isAuthenticated()) { pipeline.addFirst("proxy", new HttpProxyHandler(proxy.getAddress(), proxy.getUsername(), proxy.getPassword())); } else { pipeline.addFirst("proxy", new HttpProxyHandler(proxy.getAddress())); } - - break; - case SOCKS4: + } + case SOCKS4 -> { if (proxy.isAuthenticated()) { pipeline.addFirst("proxy", new Socks4ProxyHandler(proxy.getAddress(), proxy.getUsername())); } else { pipeline.addFirst("proxy", new Socks4ProxyHandler(proxy.getAddress())); } - - break; - case SOCKS5: + } + case SOCKS5 -> { if (proxy.isAuthenticated()) { pipeline.addFirst("proxy", new Socks5ProxyHandler(proxy.getAddress(), proxy.getUsername(), proxy.getPassword())); } else { pipeline.addFirst("proxy", new Socks5ProxyHandler(proxy.getAddress())); } - - break; - default: - throw new UnsupportedOperationException("Unsupported proxy type: " + proxy.getType()); + } + default -> throw new UnsupportedOperationException("Unsupported proxy type: " + proxy.getType()); } } } @@ -304,26 +287,26 @@ public class TcpClientSession extends TcpSession { } switch (TransportHelper.determineTransportMethod()) { - case IO_URING: + case IO_URING -> { EVENT_LOOP_GROUP = new IOUringEventLoopGroup(newThreadFactory()); CHANNEL_CLASS = IOUringSocketChannel.class; DATAGRAM_CHANNEL_CLASS = IOUringDatagramChannel.class; - break; - case EPOLL: + } + case EPOLL -> { EVENT_LOOP_GROUP = new EpollEventLoopGroup(newThreadFactory()); CHANNEL_CLASS = EpollSocketChannel.class; DATAGRAM_CHANNEL_CLASS = EpollDatagramChannel.class; - break; - case KQUEUE: + } + case KQUEUE -> { EVENT_LOOP_GROUP = new KQueueEventLoopGroup(newThreadFactory()); CHANNEL_CLASS = KQueueSocketChannel.class; DATAGRAM_CHANNEL_CLASS = KQueueDatagramChannel.class; - break; - case NIO: + } + case NIO -> { EVENT_LOOP_GROUP = new NioEventLoopGroup(newThreadFactory()); CHANNEL_CLASS = NioSocketChannel.class; DATAGRAM_CHANNEL_CLASS = NioDatagramChannel.class; - break; + } } Runtime.getRuntime().addShutdownHook(new Thread( diff --git a/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketCompression.java b/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketCompression.java index 57e55bec..d8b46419 100644 --- a/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketCompression.java +++ b/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketCompression.java @@ -34,7 +34,7 @@ public class TcpPacketCompression extends ByteToMessageCodec { } @Override - public void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception { + public void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) { int readable = in.readableBytes(); if(readable < this.session.getCompressionThreshold()) { this.session.getCodecHelper().writeVarInt(out, 0); diff --git a/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketSizer.java b/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketSizer.java index a114d9df..8b43482d 100644 --- a/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketSizer.java +++ b/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketSizer.java @@ -1,7 +1,6 @@ package com.github.steveice10.packetlib.tcp; import com.github.steveice10.packetlib.Session; -import com.github.steveice10.packetlib.codec.PacketCodecHelper; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; @@ -20,7 +19,7 @@ public class TcpPacketSizer extends ByteToMessageCodec { } @Override - public void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception { + public void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) { int length = in.readableBytes(); out.ensureWritable(this.session.getPacketProtocol().getPacketHeader().getLengthSize(length) + length); this.session.getPacketProtocol().getPacketHeader().writeLength(out, this.session.getCodecHelper(), length); @@ -28,7 +27,7 @@ public class TcpPacketSizer extends ByteToMessageCodec { } @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List out) throws Exception { + protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List out) { buf.markReaderIndex(); byte[] lengthBytes = new byte[size]; for (int index = 0; index < lengthBytes.length; index++) { diff --git a/src/main/java/com/github/steveice10/packetlib/tcp/TcpServer.java b/src/main/java/com/github/steveice10/packetlib/tcp/TcpServer.java index 6b935f35..538e4547 100644 --- a/src/main/java/com/github/steveice10/packetlib/tcp/TcpServer.java +++ b/src/main/java/com/github/steveice10/packetlib/tcp/TcpServer.java @@ -5,13 +5,6 @@ import com.github.steveice10.packetlib.BuiltinFlags; import com.github.steveice10.packetlib.helper.TransportHelper; import com.github.steveice10.packetlib.packet.PacketProtocol; import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOption; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.EventLoopGroup; import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.epoll.EpollServerSocketChannel; import io.netty.channel.*; @@ -23,7 +16,6 @@ import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.incubator.channel.uring.IOUringEventLoopGroup; import io.netty.incubator.channel.uring.IOUringServerSocketChannel; import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; import java.net.InetSocketAddress; import java.util.function.Supplier; @@ -49,25 +41,25 @@ public class TcpServer extends AbstractServer { } switch (TransportHelper.determineTransportMethod()) { - case IO_URING: + case IO_URING -> { this.group = new IOUringEventLoopGroup(); this.serverSocketChannel = IOUringServerSocketChannel.class; - break; - case EPOLL: + } + case EPOLL -> { this.group = new EpollEventLoopGroup(); this.serverSocketChannel = EpollServerSocketChannel.class; - break; - case KQUEUE: + } + case KQUEUE -> { this.group = new KQueueEventLoopGroup(); this.serverSocketChannel = KQueueServerSocketChannel.class; - break; - case NIO: + } + case NIO -> { this.group = new NioEventLoopGroup(); this.serverSocketChannel = NioServerSocketChannel.class; - break; + } } - ChannelFuture future = new ServerBootstrap().channel(this.serverSocketChannel).childHandler(new ChannelInitializer() { + ChannelFuture future = new ServerBootstrap().channel(this.serverSocketChannel).childHandler(new ChannelInitializer<>() { @Override public void initChannel(Channel channel) { InetSocketAddress address = (InetSocketAddress) channel.remoteAddress(); @@ -165,14 +157,11 @@ public class TcpServer extends AbstractServer { } catch(InterruptedException e) { } } else { - future.addListener(new GenericFutureListener() { - @Override - public void operationComplete(Future future) { - if(!future.isSuccess() && getGlobalFlag(BuiltinFlags.PRINT_DEBUG, false)) { - System.err.println("[ERROR] Failed to asynchronously close connection listener."); - if(future.cause() != null) { - future.cause().printStackTrace(); - } + future.addListener(future1 -> { + if(!future1.isSuccess() && getGlobalFlag(BuiltinFlags.PRINT_DEBUG, false)) { + System.err.println("[ERROR] Failed to asynchronously close connection listener."); + if(future1.cause() != null) { + future1.cause().printStackTrace(); } } }); diff --git a/src/main/java/com/github/steveice10/packetlib/tcp/TcpSession.java b/src/main/java/com/github/steveice10/packetlib/tcp/TcpSession.java index a15d370e..4045b065 100644 --- a/src/main/java/com/github/steveice10/packetlib/tcp/TcpSession.java +++ b/src/main/java/com/github/steveice10/packetlib/tcp/TcpSession.java @@ -17,7 +17,7 @@ import io.netty.handler.timeout.WriteTimeoutException; import io.netty.handler.timeout.WriteTimeoutHandler; import io.netty.util.concurrent.DefaultThreadFactory; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import java.net.ConnectException; import java.net.SocketAddress; diff --git a/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java b/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java index d63b698f..b2938667 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java @@ -110,7 +110,7 @@ public class MinecraftProtocolTest { } private static class ServerInfoHandlerTest implements ServerInfoHandler { - public CountDownLatch status = new CountDownLatch(1); + public final CountDownLatch status = new CountDownLatch(1); public ServerStatusInfo info; @Override @@ -121,7 +121,7 @@ public class MinecraftProtocolTest { } private static class LoginListenerTest extends SessionAdapter { - public CountDownLatch login = new CountDownLatch(1); + public final CountDownLatch login = new CountDownLatch(1); public ClientboundLoginPacket packet; @Override diff --git a/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelChunkWithLightPacketTest.java b/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelChunkWithLightPacketTest.java index be1f43e6..6c70e90a 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelChunkWithLightPacketTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundLevelChunkWithLightPacketTest.java @@ -7,13 +7,12 @@ import com.github.steveice10.mc.protocol.packet.PacketTest; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import org.junit.jupiter.api.BeforeEach; -import java.io.IOException; import java.util.BitSet; import java.util.Collections; public class ClientboundLevelChunkWithLightPacketTest extends PacketTest { @BeforeEach - public void setup() throws IOException { + public void setup() { this.setPackets( new ClientboundLevelChunkWithLightPacket(0, 0, new byte[0], new CompoundTag(""), new BlockEntityInfo[0], diff --git a/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetEntityDataPacketTest.java b/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetEntityDataPacketTest.java index ba6b2241..6bcf6606 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetEntityDataPacketTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSetEntityDataPacketTest.java @@ -21,11 +21,11 @@ public class ClientboundSetEntityDataPacketTest extends PacketTest { @BeforeEach public void setup() { this.setPackets( - new ClientboundSetEntityDataPacket(0, new EntityMetadata[0]), - new ClientboundSetEntityDataPacket(20, new EntityMetadata[] { + new ClientboundSetEntityDataPacket(0, new EntityMetadata[0]), + new ClientboundSetEntityDataPacket(20, new EntityMetadata[] { new ObjectEntityMetadata<>(1, MetadataType.STRING, "Hello!") }), - new ClientboundSetEntityDataPacket(2, new EntityMetadata[] { + new ClientboundSetEntityDataPacket(2, new EntityMetadata[] { new BooleanEntityMetadata(0, MetadataType.BOOLEAN, true), new ByteEntityMetadata(4, MetadataType.BYTE, (byte) 45), new IntEntityMetadata(2, MetadataType.INT, 555), @@ -36,7 +36,7 @@ public class ClientboundSetEntityDataPacketTest extends PacketTest { new ObjectEntityMetadata<>(6, MetadataType.DIRECTION, Direction.EAST), new ObjectEntityMetadata<>(7, MetadataType.OPTIONAL_VARINT, OptionalInt.of(1038)) }), - new ClientboundSetEntityDataPacket(700, new EntityMetadata[] { + new ClientboundSetEntityDataPacket(700, new EntityMetadata[] { // Boxed variation test new ObjectEntityMetadata<>(0, MetadataType.INT, 0), new ObjectEntityMetadata<>(1, MetadataType.FLOAT, 1.0f)