summaryrefslogtreecommitdiff
path: root/shared/src/main/java/kz/ilotterytea/frogartha/domain
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-01-28 22:44:58 +0500
committerilotterytea <iltsu@alright.party>2025-01-28 22:44:58 +0500
commit835c2fdb6c1f1064ebb0eece8816cd4edfee3ec8 (patch)
tree04e0dc3591329010b4bee7720cfe51612a494c72 /shared/src/main/java/kz/ilotterytea/frogartha/domain
parent76c0903ea857ff9bf31fe3cf75a3a41d3ee2ec06 (diff)
feat: set the server constants on connect
Diffstat (limited to 'shared/src/main/java/kz/ilotterytea/frogartha/domain')
-rw-r--r--shared/src/main/java/kz/ilotterytea/frogartha/domain/events/ServerOptionsEvent.java83
1 files changed, 83 insertions, 0 deletions
diff --git a/shared/src/main/java/kz/ilotterytea/frogartha/domain/events/ServerOptionsEvent.java b/shared/src/main/java/kz/ilotterytea/frogartha/domain/events/ServerOptionsEvent.java
new file mode 100644
index 0000000..7393375
--- /dev/null
+++ b/shared/src/main/java/kz/ilotterytea/frogartha/domain/events/ServerOptionsEvent.java
@@ -0,0 +1,83 @@
+package kz.ilotterytea.frogartha.domain.events;
+
+import com.github.czyzby.websocket.serialization.SerializationException;
+import com.github.czyzby.websocket.serialization.Transferable;
+import com.github.czyzby.websocket.serialization.impl.Deserializer;
+import com.github.czyzby.websocket.serialization.impl.Serializer;
+import kz.ilotterytea.frogartha.FrogarthaConstants;
+
+public class ServerOptionsEvent extends Event implements Transferable<ServerOptionsEvent> {
+ private final int chatMaxMessageLength, chatMessagePerMilliseconds;
+ private final float playerMaxJumpStrength, playerMaxJumpHeight, playerJumpSpeed;
+
+ public ServerOptionsEvent() {
+ this.chatMaxMessageLength = FrogarthaConstants.Chat.MAX_MESSAGE_LENGTH;
+ this.chatMessagePerMilliseconds = FrogarthaConstants.Chat.MESSAGE_PER_MS;
+ this.playerMaxJumpStrength = FrogarthaConstants.Player.MAX_JUMP_STRENGTH;
+ this.playerMaxJumpHeight = FrogarthaConstants.Player.MAX_JUMP_HEIGHT;
+ this.playerJumpSpeed = FrogarthaConstants.Player.JUMP_SPEED;
+ }
+
+ public ServerOptionsEvent(
+ int chatMaxMessageLength, int chatMessagePerMilliseconds,
+ float playerMaxJumpStrength, float playerMaxJumpHeight, float playerJumpSpeed
+ ) {
+ this.chatMaxMessageLength = chatMaxMessageLength;
+ this.chatMessagePerMilliseconds = chatMessagePerMilliseconds;
+ this.playerMaxJumpStrength = playerMaxJumpStrength;
+ this.playerMaxJumpHeight = playerMaxJumpHeight;
+ this.playerJumpSpeed = playerJumpSpeed;
+ }
+
+ public int getChatMaxMessageLength() {
+ return chatMaxMessageLength;
+ }
+
+ public int getChatMessagePerMilliseconds() {
+ return chatMessagePerMilliseconds;
+ }
+
+ public float getPlayerMaxJumpStrength() {
+ return playerMaxJumpStrength;
+ }
+
+ public float getPlayerMaxJumpHeight() {
+ return playerMaxJumpHeight;
+ }
+
+ public float getPlayerJumpSpeed() {
+ return playerJumpSpeed;
+ }
+
+ @Override
+ public void serialize(Serializer serializer) throws SerializationException {
+ serializer
+ .serializeInt(chatMaxMessageLength)
+ .serializeInt(chatMessagePerMilliseconds)
+ .serializeFloat(playerMaxJumpStrength)
+ .serializeFloat(playerMaxJumpHeight)
+ .serializeFloat(playerJumpSpeed);
+ }
+
+ @Override
+ public ServerOptionsEvent deserialize(Deserializer deserializer) throws SerializationException {
+ return new ServerOptionsEvent(
+ deserializer.deserializeInt(),
+ deserializer.deserializeInt(),
+ deserializer.deserializeFloat(),
+ deserializer.deserializeFloat(),
+ deserializer.deserializeFloat()
+ );
+ }
+
+ @Override
+ public String toString() {
+ return "ServerOptionsEvent{" +
+ "chatMaxMessageLength=" + chatMaxMessageLength +
+ ", chatMessagePerMilliseconds=" + chatMessagePerMilliseconds +
+ ", playerMaxJumpStrength=" + playerMaxJumpStrength +
+ ", playerMaxJumpHeight=" + playerMaxJumpHeight +
+ ", playerJumpSpeed=" + playerJumpSpeed +
+ '}';
+ }
+}