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.gui.commands;
00023
00024 import com.realtime.crossfire.jxclient.gui.item.GUIItemItem;
00025 import com.realtime.crossfire.jxclient.items.CfItem;
00026 import com.realtime.crossfire.jxclient.queue.CommandQueue;
00027 import com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection;
00028 import org.jetbrains.annotations.NotNull;
00029 import org.jetbrains.annotations.Nullable;
00030
00035 public enum CommandType {
00036
00040 APPLY {
00042 @Override
00043 protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
00044 crossfireServerConnection.sendApply(item.getTag());
00045 }
00046 },
00047
00051 DROP {
00053 @Override
00054 protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
00055 if (item.isLocked()) {
00056 crossfireServerConnection.drawInfo("This item is locked. To drop it, first unlock by SHIFT+left-clicking on it.", 3);
00057 } else {
00058 commandQueue.sendMove(floor, item.getTag());
00059 }
00060 }
00061 },
00062
00066 EXAMINE {
00068 @Override
00069 protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
00070 crossfireServerConnection.sendExamine(item.getTag());
00071 }
00072 },
00073
00077 LOCK {
00079 @Override
00080 protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
00081 crossfireServerConnection.sendLock(true, item.getTag());
00082 }
00083 },
00084
00088 LOCK_TOGGLE {
00090 @Override
00091 protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
00092 crossfireServerConnection.sendLock(!item.isLocked(), item.getTag());
00093 }
00094 },
00095
00099 MARK {
00101 @Override
00102 protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
00103 crossfireServerConnection.sendMark(item.getTag());
00104 }
00105 },
00106
00110 UNLOCK {
00112 @Override
00113 protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
00114 crossfireServerConnection.sendLock(false, item.getTag());
00115 }
00116 },;
00117
00123 public static boolean canExecute(@Nullable final GUIItemItem guiItem) {
00124 return guiItem != null && guiItem.getItem() != null;
00125 }
00126
00134 public void execute(@Nullable final GUIItemItem guiItem, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
00135 if (guiItem == null) {
00136 return;
00137 }
00138
00139 final CfItem item = guiItem.getItem();
00140 if (item == null) {
00141 return;
00142 }
00143
00144 doExecute(item, crossfireServerConnection, floor, commandQueue);
00145 }
00146
00154 protected abstract void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue);
00155
00156 }