From 347ed152b84209725c972820b00a1efd9505dec7 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Mon, 2 Dec 2024 18:58:15 +0100 Subject: [PATCH] Added 'IncorrectRequestMessage' class. Added the 'IncorrectRequestMessage' class to this project. It will be used to send the client an incorrect request message to show they did something wrong. --- .../server/IncorrectRequestMessage.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/message/server/IncorrectRequestMessage.java diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/message/server/IncorrectRequestMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/IncorrectRequestMessage.java new file mode 100644 index 00000000..eeae3717 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/IncorrectRequestMessage.java @@ -0,0 +1,58 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +@Serializable +public class IncorrectRequestMessage extends ServerMessage { + /** + * Create IncorrectRequestMessage attributes. + */ + private final int id; + + /** + * Constructor. + * + * @param id as the id of the error message as an Integer. + */ + public IncorrectRequestMessage(int id) { + this.id = id; + } + + /** + * Constructor. + */ + public IncorrectRequestMessage() { + this.id = 0; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.process(this); + } + + /** + * Gets the bundle key of the informational text to be shown at the client. + * This key is used to retrieve the appropriate localized text for display. + * + * @return the bundle key of the informational text + */ + @Override + public String getInfoTextKey() { + return ""; + } + + /** + * This method will be used to return necessary class information in a more readable format. + * + * @return information as a String. + */ + @Override + public String toString() { + return "IncorrectRequestMessage with id: %d".formatted(this.id); + } +}