Crossfire JXClient, Trunk  R20561
AbstractCommand.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.commands;
23 
26 import org.jetbrains.annotations.NotNull;
27 
32 public abstract class AbstractCommand implements Command {
33 
37  @NotNull
38  private final String commandName;
39 
43  @NotNull
45 
51  protected AbstractCommand(@NotNull final String commandName, @NotNull final CrossfireServerConnection crossfireServerConnection) {
52  this.commandName = commandName;
53  this.crossfireServerConnection = crossfireServerConnection;
54  }
55 
60  protected void drawInfo(@NotNull final String message) {
62  }
63 
68  protected void drawInfoError(@NotNull final String message) {
70  }
71 
77  protected void drawInfo(@NotNull final String message, final int color) {
78  crossfireServerConnection.drawInfo(message, color);
79  }
80 
84  @NotNull
85  @Override
86  public String getCommandName() {
87  return commandName;
88  }
89 
93  @NotNull
94  @Override
95  public String toString() {
96  return commandName;
97  }
98 
99 }
Abstract base class for Command implementations.
Implements a client-side command.
Definition: Command.java:30
Interface for listeners interested in drawinfo messages received from the Crossfire server...
void drawInfoError(@NotNull final String message)
Displays an error message.
final CrossfireServerConnection crossfireServerConnection
The connection instance.
void drawInfo(@NotNull String message, int color)
Pretends that a drawinfo message has been received.
String getCommandName()
Returns the name of the command.the name
AbstractCommand(@NotNull final String commandName, @NotNull final CrossfireServerConnection crossfireServerConnection)
Creates a new instance.
final String commandName
The name of the command.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
void drawInfo(@NotNull final String message)
Displays a regular output message.
void drawInfo(@NotNull final String message, final int color)
Displays a message.