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.textinput.CommandCallback;
00025 import com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection;
00026 import org.jetbrains.annotations.NotNull;
00027
00032 public class UnbindCommand extends AbstractCommand {
00033
00037 @NotNull
00038 private final CommandCallback commandCallback;
00039
00045 public UnbindCommand(@NotNull final CommandCallback commandCallback, @NotNull final CrossfireServerConnection crossfireServerConnection) {
00046 super("unbind", crossfireServerConnection);
00047 this.commandCallback = commandCallback;
00048 }
00049
00053 @Override
00054 public boolean allArguments() {
00055 return false;
00056 }
00057
00061 @Override
00062 public void execute(@NotNull final String args) {
00063 final CharSequence commands;
00064 final boolean perCharacterBinding;
00065 if (args.equals("-c")) {
00066 perCharacterBinding = true;
00067 commands = "";
00068 } else if (args.startsWith("-c ")) {
00069 perCharacterBinding = true;
00070 commands = args.substring(3).trim();
00071 } else {
00072 perCharacterBinding = false;
00073 commands = args;
00074 }
00075
00076 if (commands.length() != 0) {
00077 drawInfoError("No arguments allowed.");
00078 return;
00079 }
00080
00081 if (!commandCallback.removeKeyBinding(perCharacterBinding)) {
00082 drawInfoError("Cannot use unbind -c since no character is logged in.");
00083
00084 return;
00085 }
00086 }
00087
00088 }