]> git.basschouten.com Git - openhab-addons.git/blob
712395d36587b65b313221d2ca41d97cdf1a3d9e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.minecraft.internal.message;
14
15 import com.google.gson.JsonElement;
16
17 /**
18  * Message used for communicating with Minecraft server.
19  * Used both for sending and receiving messages.
20  *
21  * @author Mattias Markehed - Initial contribution
22  */
23 public class OHMessage {
24
25     public static final int MESSAGE_TYPE_PLAYERS = 1;
26     public static final int MESSAGE_TYPE_SERVERS = 2;
27     public static final int MESSAGE_TYPE_SIGNS = 4;
28     public static final int MESSAGE_TYPE_PLAYER_COMMANDS = 3;
29     public static final int MESSAGE_TYPE_SIGN_COMMANDS = 5;
30
31     private int messageType;
32     private JsonElement message;
33
34     /**
35      * Creates a message of type.
36      *
37      * @param messageType the message type.
38      * @param message message data.
39      */
40     public OHMessage(int messageType, JsonElement message) {
41         this.messageType = messageType;
42         this.message = message;
43     }
44
45     /**
46      * Get the type of message
47      *
48      * @return type of message
49      */
50     public int getMessageType() {
51         return messageType;
52     }
53
54     /**
55      * Set message type.
56      *
57      * @param messageType the type of message
58      */
59     public void setMessageType(int messageType) {
60         this.messageType = messageType;
61     }
62
63     /**
64      * Get messsage data.
65      *
66      * @return
67      */
68     public JsonElement getMessage() {
69         return message;
70     }
71
72     /**
73      * Set the message to send.
74      *
75      * @param message
76      */
77     public void setMessage(JsonElement message) {
78         this.message = message;
79     }
80 }