summaryrefslogtreecommitdiff
path: root/shared/src/main/java/kz/ilotterytea/frogartha/exceptions/PlayerKickException.java
blob: ad9c408b6a5da27400690979d0b8d59a37889111 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package kz.ilotterytea.frogartha.exceptions;

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;

public class PlayerKickException extends RuntimeException implements Transferable<PlayerKickException> {
    public PlayerKickException() {
    }

    private PlayerKickException(String message) {
        super(message);
    }

    public static PlayerKickException loggedIn() {
        return new PlayerKickException("You logged in from another location");
    }

    public static PlayerKickException internalServerError() {
        return new PlayerKickException("Internal Server Error");
    }

    public static PlayerKickException jumpSpam() {
        return new PlayerKickException("Kicked for jump spamming");
    }

    public static PlayerKickException illegalOperation() {
        return new PlayerKickException("Illegal operation");
    }

    public static PlayerKickException notInRoom() {
        return new PlayerKickException("You are not in room");
    }

    @Override
    public void serialize(Serializer serializer) throws SerializationException {
        serializer.serializeString(getMessage());
    }

    @Override
    public PlayerKickException deserialize(Deserializer deserializer) throws SerializationException {
        return new PlayerKickException(deserializer.deserializeString());
    }
}