Crossfire JXClient, Trunk
DebugMessagesCommand.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-2017,2019-2023 Andreas Kirschbaum
20  * Copyright (C) 2010-2012,2014-2018,2020-2023 Nicolas Weeger
21  */
22 
23 package com.realtime.crossfire.jxclient.commands;
24 
28 import org.jetbrains.annotations.NotNull;
29 
35 public class DebugMessagesCommand extends AbstractCommand {
36 
40  @NotNull
42 
48  super("debug_messages", crossfireServerConnection);
49  this.crossfireServerConnection = crossfireServerConnection;
50  }
51 
52  @Override
53  public boolean allArguments() {
54  return false;
55  }
56 
57  @Override
58  public void execute(@NotNull final String args) {
59  switch (args) {
60  case "colors":
61  for (int color = 0; color < MessageBufferUpdater.NUM_COLORS; color++) {
62  drawInfo("This line is color #"+color+" ("+MessageBufferUpdater.getColorName(color)+").", color);
63  }
64  break;
65 
66  case "types":
67  for (int type : MessageType.getAllTypes(true)) {
68  crossfireServerConnection.drawextinfo(0, type, 0, "This line is type #"+type+".");
69  }
70  break;
71 
72  case "on":
74  break;
75 
76  case "off":
78  break;
79 
80  default:
81  drawInfoError("Valid arguments are 'colors', 'types', 'on', or 'off'. 'colors' prints messages using different message colors, 'types' prints messages using different message types, 'on' and 'off' enables/disables printing of message types.");
82  break;
83  }
84  }
85 
86  @NotNull
87  @Override
88  public String getHelp() {
89  //noinspection StringBufferReplaceableByString
90  final StringBuilder sb = new StringBuilder();
91  sb.append("Prints information for debugging the client\n");
92  sb.append("\n");
93  sb.append("Usage: debug_messages colors\n");
94  sb.append("Usage: debug_messages types\n");
95  sb.append("Usage: debug_messages on\n");
96  sb.append("Usage: debug_messages off\n");
97  sb.append("\n");
98  sb.append("'colors' prints messages using different message colors, ");
99  sb.append("'types' prints messages using different message types, ");
100  sb.append("'on' and 'off' enables/disables printing of message types.\n");
101  return sb.toString();
102  }
103 
104 }
com.realtime.crossfire.jxclient
com.realtime.crossfire.jxclient.commands.DebugMessagesCommand.execute
void execute(@NotNull final String args)
Definition: DebugMessagesCommand.java:58
com.realtime.crossfire.jxclient.server
com.realtime.crossfire.jxclient.commands.DebugMessagesCommand.DebugMessagesCommand
DebugMessagesCommand(@NotNull final CrossfireServerConnection crossfireServerConnection)
Definition: DebugMessagesCommand.java:47
com.realtime.crossfire.jxclient.commands.DebugMessagesCommand.allArguments
boolean allArguments()
Definition: DebugMessagesCommand.java:53
com.realtime.crossfire.jxclient.gui.log.MessageBufferUpdater.getColorName
static String getColorName(final int index)
Definition: MessageBufferUpdater.java:241
com.realtime.crossfire.jxclient.gui.log
Definition: Buffer.java:23
com.realtime.crossfire.jxclient.protocol
Definition: MagicMap.java:23
com.realtime.crossfire.jxclient.commands.AbstractCommand.drawInfoError
void drawInfoError(@NotNull final String message)
Definition: AbstractCommand.java:69
com.realtime.crossfire.jxclient.commands.DebugMessagesCommand.getHelp
String getHelp()
Definition: DebugMessagesCommand.java:88
com.realtime.crossfire.jxclient.gui.log.MessageBufferUpdater.NUM_COLORS
static final int NUM_COLORS
Definition: MessageBufferUpdater.java:43
com.realtime.crossfire.jxclient.protocol.MessageType
Definition: MessageType.java:33
com.realtime.crossfire.jxclient.protocol.MessageType.getAllTypes
static int[] getAllTypes(final boolean includeJXClientType)
Definition: MessageType.java:744
com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection
Definition: CrossfireServerConnection.java:37
com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection.drawInfoSetDebugMode
void drawInfoSetDebugMode(boolean printMessageTypes)
com.realtime.crossfire.jxclient.gui
com.realtime.crossfire.jxclient.commands.DebugMessagesCommand
Definition: DebugMessagesCommand.java:35
com.realtime.crossfire.jxclient.gui.log.MessageBufferUpdater
Definition: MessageBufferUpdater.java:38
com.realtime.crossfire.jxclient.server.crossfire
Definition: AbstractCrossfireServerConnection.java:23
com.realtime.crossfire
com.realtime.crossfire.jxclient.commands.AbstractCommand.drawInfo
void drawInfo(@NotNull final String message)
Definition: AbstractCommand.java:61
com.realtime
com
com.realtime.crossfire.jxclient.commands.DebugMessagesCommand.crossfireServerConnection
final CrossfireServerConnection crossfireServerConnection
Definition: DebugMessagesCommand.java:41
com.realtime.crossfire.jxclient.commands.AbstractCommand
Definition: AbstractCommand.java:33
com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection.drawextinfo
void drawextinfo(int color, int type, int subtype, String message)