Crossfire JXClient, Trunk  R20561
MessageTypes.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.protocol;
23 
24 import org.jetbrains.annotations.NotNull;
25 
30 public class MessageTypes {
31 
36  public static final int MSG_TYPE_QUERY = 30;
37 
41  public static final int MSG_TYPE_BOOK = 1;
42 
46  public static final int MSG_TYPE_CARD = 2;
47 
51  public static final int MSG_TYPE_PAPER = 3;
52 
56  public static final int MSG_TYPE_SIGN = 4;
57 
61  public static final int MSG_TYPE_MONUMENT = 5;
62 
66  public static final int MSG_TYPE_DIALOG = 6;
67 
71  public static final int MSG_TYPE_MOTD = 7;
72 
76  public static final int MSG_TYPE_ADMIN = 8;
77 
81  public static final int MSG_TYPE_SHOP = 9;
82 
86  public static final int MSG_TYPE_COMMAND = 10;
87 
92  public static final int MSG_TYPE_ATTRIBUTE = 11;
93 
97  public static final int MSG_TYPE_SKILL = 12;
98 
102  public static final int MSG_TYPE_APPLY = 13;
103 
107  public static final int MSG_TYPE_ATTACK = 14;
108 
112  public static final int MSG_TYPE_COMMUNICATION = 15;
113 
117  public static final int MSG_TYPE_SPELL = 16;
118 
122  public static final int MSG_TYPE_ITEM = 17;
123 
128  public static final int MSG_TYPE_MISC = 18;
129 
133  public static final int MSG_TYPE_VICTIM = 19;
134 
135  public static final int MSG_TYPE_BOOK_CLASP_1 = 1;
136 
137  public static final int MSG_TYPE_BOOK_CLASP_2 = 2;
138 
139  public static final int MSG_TYPE_BOOK_ELEGANT_1 = 3;
140 
141  public static final int MSG_TYPE_BOOK_ELEGANT_2 = 4;
142 
143  public static final int MSG_TYPE_BOOK_QUARTO_1 = 5;
144 
145  public static final int MSG_TYPE_BOOK_QUARTO_2 = 6;
146 
147  public static final int MSG_TYPE_BOOK_SPELL_EVOKER = 8;
148 
149  public static final int MSG_TYPE_BOOK_SPELL_PRAYER = 9;
150 
151  public static final int MSG_TYPE_BOOK_SPELL_PYRO = 10;
152 
153  public static final int MSG_TYPE_BOOK_SPELL_SORCERER = 11;
154 
155  public static final int MSG_TYPE_BOOK_SPELL_SUMMONER = 12;
156 
157  public static final int MSG_TYPE_COMMUNICATION_RANDOM = 1; // random event (coin toss)
158 
159  public static final int MSG_TYPE_COMMUNICATION_SAY = 2; // player says something
160 
161  public static final int MSG_TYPE_COMMUNICATION_ME = 3; // player me's a message
162 
163  public static final int MSG_TYPE_COMMUNICATION_TELL = 4; // player tells something
164 
165  public static final int MSG_TYPE_COMMUNICATION_EMOTE = 5; // player emotes
166 
167  public static final int MSG_TYPE_COMMUNICATION_PARTY = 6; // party message
168 
169  public static final int MSG_TYPE_COMMUNICATION_SHOUT = 7; // shout message
170 
171  public static final int MSG_TYPE_COMMUNICATION_CHAT = 8; // chat message
172 
176  private MessageTypes() {
177  }
178 
183  @NotNull
184  public static int[] getAllTypes() {
185  return new int[] {
205  };
206  }
207 
214  public static int parseMessageType(@NotNull final String str) throws UnknownMessageTypeException {
215  if (str.equals("BOOK")) {
216  return MSG_TYPE_BOOK;
217  }
218  if (str.equals("CARD")) {
219  return MSG_TYPE_CARD;
220  }
221  if (str.equals("PAPER")) {
222  return MSG_TYPE_PAPER;
223  }
224  if (str.equals("SIGN")) {
225  return MSG_TYPE_SIGN;
226  }
227  if (str.equals("MONUMENT")) {
228  return MSG_TYPE_MONUMENT;
229  }
230  if (str.equals("DIALOG")) {
231  return MSG_TYPE_DIALOG;
232  }
233  if (str.equals("MOTD")) {
234  return MSG_TYPE_MOTD;
235  }
236  if (str.equals("ADMIN")) {
237  return MSG_TYPE_ADMIN;
238  }
239  if (str.equals("SHOP")) {
240  return MSG_TYPE_SHOP;
241  }
242  if (str.equals("COMMAND")) {
243  return MSG_TYPE_COMMAND;
244  }
245  if (str.equals("ATTRIBUTE")) {
246  return MSG_TYPE_ATTRIBUTE;
247  }
248  if (str.equals("SKILL")) {
249  return MSG_TYPE_SKILL;
250  }
251  if (str.equals("APPLY")) {
252  return MSG_TYPE_APPLY;
253  }
254  if (str.equals("ATTACK")) {
255  return MSG_TYPE_ATTACK;
256  }
257  if (str.equals("COMMUNICATION")) {
258  return MSG_TYPE_COMMUNICATION;
259  }
260  if (str.equals("SPELL")) {
261  return MSG_TYPE_SPELL;
262  }
263  if (str.equals("ITEM")) {
264  return MSG_TYPE_ITEM;
265  }
266  if (str.equals("MISC")) {
267  return MSG_TYPE_MISC;
268  }
269  if (str.equals("VICTIM")) {
270  return MSG_TYPE_VICTIM;
271  }
272  if (str.equals("QUERY")) {
273  return MSG_TYPE_QUERY;
274  }
275  throw new UnknownMessageTypeException(str);
276  }
277 
283  @NotNull
284  public static String toString(final int type) {
285  switch (type) {
286  case MSG_TYPE_BOOK:
287  return "BOOK";
288 
289  case MSG_TYPE_CARD:
290  return "CARD";
291 
292  case MSG_TYPE_PAPER:
293  return "PAPER";
294 
295  case MSG_TYPE_SIGN:
296  return "SIGN";
297 
298  case MSG_TYPE_MONUMENT:
299  return "MONUMENT";
300 
301  case MSG_TYPE_DIALOG:
302  return "DIALOG";
303 
304  case MSG_TYPE_MOTD:
305  return "MOTD";
306 
307  case MSG_TYPE_ADMIN:
308  return "ADMIN";
309 
310  case MSG_TYPE_SHOP:
311  return "SHOP";
312 
313  case MSG_TYPE_COMMAND:
314  return "COMMAND";
315 
316  case MSG_TYPE_ATTRIBUTE:
317  return "ATTRIBUTE";
318 
319  case MSG_TYPE_SKILL:
320  return "SKILL";
321 
322  case MSG_TYPE_APPLY:
323  return "APPLY";
324 
325  case MSG_TYPE_ATTACK:
326  return "ATTACK";
327 
329  return "COMMUNICATION";
330 
331  case MSG_TYPE_SPELL:
332  return "SPELL";
333 
334  case MSG_TYPE_ITEM:
335  return "ITEM";
336 
337  case MSG_TYPE_MISC:
338  return "MISC";
339 
340  case MSG_TYPE_VICTIM:
341  return "VICTIM";
342  }
343 
344  return Integer.toString(type);
345  }
346 
347 }
static int [] getAllTypes()
Returns all defined message types.
static final int MSG_TYPE_SKILL
drawextinfo message type: message related to using skills.
Encapsulates the message type numbers for drawextinfo messages.
static final int MSG_TYPE_CARD
drawextinfo message type: character did read a card.
static final int MSG_TYPE_MISC
drawextinfo message type: message that does not fit in any other category.
static final int MSG_TYPE_MONUMENT
drawextinfo message type: character did read a monument.
static final int MSG_TYPE_PAPER
drawextinfo message type: character did read a paper.
An exception that is thrown if an undefined message type occurs.
static final int MSG_TYPE_COMMAND
drawextinfo message type: response to command processing.
static final int MSG_TYPE_ADMIN
drawextinfo message type: general server message.
static final int MSG_TYPE_ATTACK
drawextinfo message type: attack related message.
static final int MSG_TYPE_APPLY
drawextinfo message type: an object was applied.
static final int MSG_TYPE_SHOP
drawextinfo message type: shop related message.
static final int MSG_TYPE_SIGN
drawextinfo message type: character did read a sign.
static final int MSG_TYPE_ITEM
drawextinfo message type: item related information.
static final int MSG_TYPE_COMMUNICATION
drawextinfo message type: communication between players.
static final int MSG_TYPE_MOTD
drawextinfo message type: motd text.
static final int MSG_TYPE_SPELL
drawextinfo message type: spell related information.
static final int MSG_TYPE_QUERY
Internally used drawextinfo message type: a query message has been received.
MessageTypes()
Private constructor to prevent instantiation.
static final int MSG_TYPE_DIALOG
drawextinfo message type: a NPC/magic mouth/altar/etc.
static final int MSG_TYPE_ATTRIBUTE
drawextinfo message type: attribute (stats, resistances, etc.) change message.
static final int MSG_TYPE_VICTIM
drawextinfo message type: something bad is happening to the player.
static int parseMessageType(@NotNull final String str)
Parses a string into a message type.
static final int MSG_TYPE_BOOK
drawextinfo message type: character did read a book.
static String toString(final int type)
Returns a string representation of a message type.