00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 package com.realtime.crossfire.jxclient.commands;
00023
00024 import com.realtime.crossfire.jxclient.gui.commandlist.CommandList;
00025 import com.realtime.crossfire.jxclient.gui.textinput.CommandCallback;
00026 import com.realtime.crossfire.jxclient.gui.textinput.NoSuchCommandException;
00027 import com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection;
00028 import org.jetbrains.annotations.NotNull;
00029
00034 public class ExecCommand extends AbstractCommand {
00035
00039 @NotNull
00040 private final CommandCallback commandCallback;
00041
00047 public ExecCommand(@NotNull final CommandCallback commandCallback, @NotNull final CrossfireServerConnection crossfireServerConnection) {
00048 super("exec", crossfireServerConnection);
00049 this.commandCallback = commandCallback;
00050 }
00051
00055 @Override
00056 public boolean allArguments() {
00057 return false;
00058 }
00059
00063 @Override
00064 public void execute(@NotNull final String args) {
00065 if (args.length() == 0) {
00066 drawInfoError("Which command do you want to run?");
00067 return;
00068 }
00069
00070 final CommandList commandList;
00071 try {
00072 commandList = commandCallback.getCommandList(args);
00073 } catch (final NoSuchCommandException ex) {
00074 drawInfoError(ex.getMessage());
00075 return;
00076 }
00077 commandList.execute();
00078 }
00079
00080 }