diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientCraftingBookStatePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientCraftingBookStatePacket.java index 46438f4f..29dd94d3 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientCraftingBookStatePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientCraftingBookStatePacket.java @@ -8,20 +8,18 @@ import com.github.steveice10.packetlib.packet.Packet; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.NonNull; -import lombok.ToString; +import lombok.Setter; import lombok.With; import java.io.IOException; @Data @With -@ToString -@EqualsAndHashCode +@Setter(AccessLevel.NONE) @NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor public class ClientCraftingBookStatePacket implements Packet { private @NonNull CraftingBookStateType type; private boolean bookOpen; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientDisplayedRecipePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientDisplayedRecipePacket.java index 4f4b445c..1eac3b7d 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientDisplayedRecipePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientDisplayedRecipePacket.java @@ -6,20 +6,18 @@ import com.github.steveice10.packetlib.packet.Packet; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.NonNull; -import lombok.ToString; +import lombok.Setter; import lombok.With; import java.io.IOException; @Data @With -@ToString -@EqualsAndHashCode +@Setter(AccessLevel.NONE) @NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor public class ClientDisplayedRecipePacket implements Packet { private @NonNull String recipeId; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/player/ServerPlayerActionAckPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/player/ServerPlayerActionAckPacket.java index e358376e..b47d8b5c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/player/ServerPlayerActionAckPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/player/ServerPlayerActionAckPacket.java @@ -25,7 +25,7 @@ public class ServerPlayerActionAckPacket implements Packet { private @NonNull PlayerAction action; private boolean successful; private @NonNull Position position; - private @NonNull int newState; + private int newState; @Override public void read(NetInput in) throws IOException { diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/player/ServerPlayerPositionRotationPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/player/ServerPlayerPositionRotationPacket.java index b78d7c50..56f4d59e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/player/ServerPlayerPositionRotationPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/player/ServerPlayerPositionRotationPacket.java @@ -9,6 +9,7 @@ import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.NonNull; import lombok.Setter; import lombok.With; @@ -21,7 +22,7 @@ import java.util.List; @With @Setter(AccessLevel.NONE) @NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor public class ServerPlayerPositionRotationPacket implements Packet { private double x; private double y; @@ -29,16 +30,10 @@ public class ServerPlayerPositionRotationPacket implements Packet { private float yaw; private float pitch; private int teleportId; - private List relative; + private @NonNull List relative; public ServerPlayerPositionRotationPacket(double x, double y, double z, float yaw, float pitch, int teleportId, PositionElement... relative) { - this.x = x; - this.y = y; - this.z = z; - this.yaw = yaw; - this.pitch = pitch; - this.teleportId = teleportId; - this.relative = Arrays.asList(relative != null ? relative : new PositionElement[0]); + this(x, y, z, yaw, pitch, teleportId, Arrays.asList(relative != null ? relative : new PositionElement[0])); } @Override diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/scoreboard/ServerScoreboardObjectivePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/scoreboard/ServerScoreboardObjectivePacket.java index 3ea600d4..56ba5378 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/scoreboard/ServerScoreboardObjectivePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/scoreboard/ServerScoreboardObjectivePacket.java @@ -28,14 +28,24 @@ public class ServerScoreboardObjectivePacket implements Packet { private Component displayName; private ScoreType type; + /** + * Constructs a ServerScoreboardObjectivePacket for removing an objective. + * @param name Name of the objective. + */ public ServerScoreboardObjectivePacket(@NonNull String name) { - this.name = name; - this.action = ObjectiveAction.REMOVE; + this(name, ObjectiveAction.REMOVE, null, null); } - public ServerScoreboardObjectivePacket(@NonNull String name, @NonNull ObjectiveAction action, @NonNull Component displayName, @NonNull ScoreType type) { - if(action != ObjectiveAction.ADD && action != ObjectiveAction.UPDATE) { - throw new IllegalArgumentException("(name, action, displayName, type) constructor only valid for adding and updating objectives."); + /** + * Constructs a ServerScoreboardObjectivePacket for adding or updating an objective. + * @param name Name of the objective. + * @param action Action to perform. + * @param displayName Display name of the objective. + * @param type Type of score. + */ + public ServerScoreboardObjectivePacket(@NonNull String name, @NonNull ObjectiveAction action, Component displayName, ScoreType type) { + if((action == ObjectiveAction.ADD || action == ObjectiveAction.UPDATE) && (displayName == null || type == null)) { + throw new IllegalArgumentException("ADD and UPDATE actions require display name and type."); } this.name = name; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/scoreboard/ServerUpdateScorePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/scoreboard/ServerUpdateScorePacket.java index c3747295..69f667b5 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/scoreboard/ServerUpdateScorePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/scoreboard/ServerUpdateScorePacket.java @@ -9,6 +9,7 @@ import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.NonNull; import lombok.Setter; import lombok.With; @@ -20,18 +21,18 @@ import java.io.IOException; @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE) public class ServerUpdateScorePacket implements Packet { - private String entry; - private ScoreboardAction action; - private String objective; + private @NonNull String entry; + private @NonNull ScoreboardAction action; + private @NonNull String objective; private int value; - public ServerUpdateScorePacket(String entry, String objective) { + public ServerUpdateScorePacket(@NonNull String entry, @NonNull String objective) { this.entry = entry; this.action = ScoreboardAction.REMOVE; this.objective = objective; } - public ServerUpdateScorePacket(String entry, String objective, int value) { + public ServerUpdateScorePacket(@NonNull String entry, @NonNull String objective, int value) { this.entry = entry; this.action = ScoreboardAction.ADD_OR_UPDATE; this.objective = objective; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java index 4ba3a7b7..9e08d506 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java @@ -11,6 +11,7 @@ import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.NonNull; import lombok.Setter; import lombok.With; @@ -23,8 +24,8 @@ import java.io.IOException; @AllArgsConstructor public class ServerBlockBreakAnimPacket implements Packet { private int breakerEntityId; - private Position position; - private BlockBreakStage stage; + private @NonNull Position position; + private @NonNull BlockBreakStage stage; @Override public void read(NetInput in) throws IOException { diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/client/LoginPluginResponsePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/client/LoginPluginResponsePacket.java index 5dfdaa5f..83c886f7 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/client/LoginPluginResponsePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/client/LoginPluginResponsePacket.java @@ -4,6 +4,7 @@ import com.github.steveice10.packetlib.io.NetInput; import com.github.steveice10.packetlib.io.NetOutput; import com.github.steveice10.packetlib.packet.Packet; import lombok.AccessLevel; +import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.Setter; @@ -15,6 +16,7 @@ import java.io.IOException; @With @Setter(AccessLevel.NONE) @NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor public class LoginPluginResponsePacket implements Packet { private int messageId; private byte[] data; @@ -23,11 +25,6 @@ public class LoginPluginResponsePacket implements Packet { this(messageId, null); } - public LoginPluginResponsePacket(int messageId, byte[] data) { - this.messageId = messageId; - this.data = data; - } - @Override public void read(NetInput in) throws IOException { this.messageId = in.readVarInt(); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/status/client/StatusQueryPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/status/client/StatusQueryPacket.java index 939cfc68..2ec27bb2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/status/client/StatusQueryPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/status/client/StatusQueryPacket.java @@ -12,7 +12,6 @@ import lombok.With; import java.io.IOException; @Data -@With @Setter(AccessLevel.NONE) @NoArgsConstructor public class StatusQueryPacket implements Packet {