diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/ErrorMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/ErrorMessage.java index 589e555..0148609 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/ErrorMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/ErrorMessage.java @@ -1,13 +1,9 @@ package uulm.teamname.marvelous.gamelibrary.messages; -import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; public class ErrorMessage extends BasicMessage{ - public final MessageType messageType = MessageType.ERROR; - - /** Some message telling the client what went wrong */ @NotNull public String message = "No message given"; @@ -15,4 +11,8 @@ public class ErrorMessage extends BasicMessage{ /** The type of the error that happened */ @NotNull public int type = 0; + + public ErrorMessage() { + messageType = MessageType.ERROR; + } } diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/CharacterSelectionMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/CharacterSelectionMessage.java index 91a50e0..501cc9d 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/CharacterSelectionMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/CharacterSelectionMessage.java @@ -9,8 +9,6 @@ import java.util.Arrays; public class CharacterSelectionMessage extends BasicMessage { - public final MessageType messageType = MessageType.CHARACTER_SELECTION; - /** * Boolean array that conveys information about what characters (6) * of the given characters (12) have been selected @@ -19,6 +17,10 @@ public class CharacterSelectionMessage extends BasicMessage { @Size(min = 12, max = 12, message = "doesn't have twelve elements") public Boolean[] characters; + public CharacterSelectionMessage() { + messageType = MessageType.CHARACTER_SELECTION; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/HelloServerMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/HelloServerMessage.java index ed9c5fc..a280931 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/HelloServerMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/HelloServerMessage.java @@ -4,12 +4,8 @@ import jakarta.validation.constraints.NotEmpty; import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage; import uulm.teamname.marvelous.gamelibrary.messages.MessageType; -import jakarta.validation.constraints.NotNull; - public class HelloServerMessage extends BasicMessage { - public final MessageType messageType = MessageType.HELLO_SERVER; - /** User-chosen name, basically a PlayerName */ @NotEmpty public String name; @@ -17,4 +13,8 @@ public class HelloServerMessage extends BasicMessage { /** Device ID sent by the Client, might be anything, but used together with name to uniquely identify the client */ @NotEmpty public String deviceID; + + public HelloServerMessage() { + messageType = MessageType.HELLO_SERVER; + } } diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/PlayerReadyMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/PlayerReadyMessage.java index 4853c2d..81d22e7 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/PlayerReadyMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/PlayerReadyMessage.java @@ -8,8 +8,6 @@ import jakarta.validation.constraints.NotNull; public class PlayerReadyMessage extends BasicMessage { - public final MessageType messageType = MessageType.PLAYER_READY; - /** Whether the client wants to start the game. If this is false, the client gets disconnected. */ @NotNull public Boolean startGame; @@ -17,4 +15,8 @@ public class PlayerReadyMessage extends BasicMessage { /** The {@link RoleEnum Role} the client wants to take */ @NotNull public RoleEnum role; + + public PlayerReadyMessage() { + messageType = MessageType.PLAYER_READY; + } } diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/ReconnectMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/ReconnectMessage.java index 7160b28..a694d1f 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/ReconnectMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/ReconnectMessage.java @@ -7,9 +7,11 @@ import jakarta.validation.constraints.NotNull; public class ReconnectMessage extends BasicMessage { - public final MessageType messageType = MessageType.RECONNECT; - /** Whether the client wants to reconnect to the previously running game */ @NotNull public Boolean reconnect; + + public ReconnectMessage() { + messageType = MessageType.RECONNECT; + } } diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/RequestMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/RequestMessage.java index ed67c38..9615a61 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/RequestMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/client/RequestMessage.java @@ -15,8 +15,6 @@ import java.util.Objects; /** Represents a message sent between client and server and contains all possible data. */ public class RequestMessage extends BasicMessage { - public final MessageType messageType = MessageType.REQUESTS; - /** The list of {@link Event Events} sent inside the message. */ @NotNull(message = "No Requests found") @NotEmpty(message = "No Requests found") @@ -28,6 +26,10 @@ public class RequestMessage extends BasicMessage { /** The decoded contents of the custom content sent. */ public HashMap customContent; + public RequestMessage() { + messageType = MessageType.REQUESTS; + } + @Override @JsonIgnore public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/ConfirmSelectionMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/ConfirmSelectionMessage.java index 03dd805..ec9f327 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/ConfirmSelectionMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/ConfirmSelectionMessage.java @@ -8,12 +8,14 @@ import java.util.Objects; public class ConfirmSelectionMessage extends BasicMessage { - public final MessageType messageType = MessageType.CONFIRM_SELECTION; - /** Whether the other player is also done with the selection already */ @NotNull public Boolean selectionComplete; + public ConfirmSelectionMessage() { + messageType = MessageType.CONFIRM_SELECTION; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/EventMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/EventMessage.java index 8067ee4..4673a71 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/EventMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/EventMessage.java @@ -15,8 +15,6 @@ import java.util.Objects; // @JsonDeserialize(using = EventMessageDeserializer.class) public class EventMessage extends BasicMessage { - public final MessageType messageType = MessageType.EVENTS; - /** The list of {@link Event Events} sent inside the message. */ @NotNull(message = "No events found") @NotEmpty(message = "No events found") @@ -28,6 +26,10 @@ public class EventMessage extends BasicMessage { /** The decoded contents of the custom content sent. */ public HashMap customContent; + public EventMessage() { + messageType = MessageType.EVENTS; + } + @Override @JsonIgnore public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GameAssignmentMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GameAssignmentMessage.java index 0d77c19..c949a35 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GameAssignmentMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GameAssignmentMessage.java @@ -13,8 +13,6 @@ import java.util.Objects; // @JsonDeserialize(using = GameAssignmentDeserializer.class) public class GameAssignmentMessage extends BasicMessage { - public final MessageType messageType = MessageType.GAME_ASSIGNMENT; - /** The ID of the game that the client is connected to. What this is used for is kind of unknown. */ @NotEmpty public String gameID; @@ -24,6 +22,10 @@ public class GameAssignmentMessage extends BasicMessage { @Size(min = 12, max = 12, message = "Character Selection doesn't have 12 booleans") public CharacterProperties[] characterSelection; + public GameAssignmentMessage() { + messageType = MessageType.GAME_ASSIGNMENT; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GameStructureMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GameStructureMessage.java index 7bbf51a..0d8dc9b 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GameStructureMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GameStructureMessage.java @@ -28,8 +28,6 @@ import java.util.stream.Stream; "matchconfig"}) public class GameStructureMessage extends BasicMessage { - public final MessageType messageType = MessageType.GAME_STRUCTURE; - /** The role the client has been assigned to */ @NotNull public ParticipantType assignment; @@ -63,6 +61,10 @@ public class GameStructureMessage extends BasicMessage { @Valid public ScenarioConfig scenarioconfig; + public GameStructureMessage() { + messageType = MessageType.GAME_STRUCTURE; + } + @JsonIgnore public CharacterConfig getCharacterConfig() { CharacterConfig characterConfig = new CharacterConfig(); characterConfig.characters = Stream diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GeneralAssignmentMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GeneralAssignmentMessage.java index 7ec6565..673e2ca 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GeneralAssignmentMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GeneralAssignmentMessage.java @@ -9,13 +9,15 @@ import java.util.Objects; public class GeneralAssignmentMessage extends BasicMessage { - public final MessageType messageType = MessageType.GENERAL_ASSIGNMENT; - /** The ID of the game that the client is connected to. What this is used for is kind of unknown. */ @NotNull @NotEmpty public String gameID; + public GeneralAssignmentMessage() { + messageType = MessageType.GENERAL_ASSIGNMENT; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GoodbyeClientMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GoodbyeClientMessage.java index b8bf4a7..2911c47 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GoodbyeClientMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/GoodbyeClientMessage.java @@ -8,9 +8,11 @@ import jakarta.validation.constraints.NotNull; public class GoodbyeClientMessage extends BasicMessage { - public final MessageType messageType = MessageType.GOODBYE_CLIENT; - /** A message sent to the client on disconnect */ @NotEmpty public String message = "You got disconnected."; + + public GoodbyeClientMessage() { + messageType = MessageType.GOODBYE_CLIENT; + } } diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/HelloClientMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/HelloClientMessage.java index 5268c52..cc060f7 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/HelloClientMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/server/HelloClientMessage.java @@ -7,9 +7,11 @@ import jakarta.validation.constraints.NotNull; public class HelloClientMessage extends BasicMessage { - public final MessageType messageType = MessageType.HELLO_CLIENT; - /** Whether there is a running game that the player disconnected from */ @NotNull public Boolean runningGame; + + public HelloClientMessage() { + messageType = MessageType.HELLO_CLIENT; + } }