Crossfire JXClient, Trunk
CommandType.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.gui.commands;
24 
30 import org.jetbrains.annotations.NotNull;
31 import org.jetbrains.annotations.Nullable;
32 
37 public enum CommandType {
38 
42  APPLY {
43  @Override
44  protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
45  crossfireServerConnection.sendApply(item.getTag());
46  }
47  },
48 
52  DROP {
53  @Override
54  protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
55  if (item.isLocked()) {
56  crossfireServerConnection.drawInfo("This item is locked. To drop it, first unlock by SHIFT+left-clicking on it.", CrossfireDrawinfoListener.NDI_RED);
57  } else {
58  commandQueue.sendMove(floor, item.getTag());
59  }
60  }
61  },
62 
66  EXAMINE {
67  @Override
68  protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
69  crossfireServerConnection.sendExamine(item.getTag());
70  }
71  },
72 
76  LOCK {
77  @Override
78  protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
79  crossfireServerConnection.sendLock(true, item.getTag());
80  }
81  },
82 
86  LOCK_TOGGLE {
87  @Override
88  protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
89  crossfireServerConnection.sendLock(!item.isLocked(), item.getTag());
90  }
91  },
92 
96  MARK {
97  @Override
98  protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
99  crossfireServerConnection.sendMark(item.getTag());
100  }
101  },
102 
106  UNLOCK {
107  @Override
108  protected void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
109  crossfireServerConnection.sendLock(false, item.getTag());
110  }
111  };
112 
118  public static boolean canExecute(@Nullable final GUIItemItem guiItem) {
119  return guiItem != null && guiItem.getItem() != null;
120  }
121 
129  public void execute(@Nullable final GUIItemItem guiItem, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue) {
130  if (guiItem == null) {
131  return;
132  }
133 
134  final CfItem item = guiItem.getItem();
135  if (item == null) {
136  return;
137  }
138 
139  doExecute(item, crossfireServerConnection, floor, commandQueue);
140  }
141 
149  protected abstract void doExecute(@NotNull final CfItem item, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue);
150 
151 }
com.realtime.crossfire.jxclient
com.realtime.crossfire.jxclient.gui.commands.CommandType
Definition: CommandType.java:37
com.realtime.crossfire.jxclient.server
com.realtime.crossfire.jxclient.gui.commands.CommandType.canExecute
static boolean canExecute(@Nullable final GUIItemItem guiItem)
Definition: CommandType.java:118
com.realtime.crossfire.jxclient.server.crossfire.CrossfireDrawinfoListener
Definition: CrossfireDrawinfoListener.java:33
com.realtime.crossfire.jxclient.gui.item.GUIItemItem
Definition: GUIItemItem.java:46
com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection
Definition: CrossfireServerConnection.java:37
com.realtime.crossfire.jxclient.gui
com.realtime.crossfire.jxclient.queue.CommandQueue
Definition: CommandQueue.java:38
com.realtime.crossfire.jxclient.items.CfItem
Definition: CfItem.java:37
com.realtime.crossfire.jxclient.server.crossfire
Definition: AbstractCrossfireServerConnection.java:23
com.realtime.crossfire.jxclient.queue
Definition: CommandQueue.java:23
com.realtime.crossfire.jxclient.gui.commands.CommandType.execute
void execute(@Nullable final GUIItemItem guiItem, @NotNull final CrossfireServerConnection crossfireServerConnection, final int floor, @NotNull final CommandQueue commandQueue)
Definition: CommandType.java:129
com.realtime.crossfire
com.realtime
com
com.realtime.crossfire.jxclient.items
Definition: AbstractItemView.java:23
com.realtime.crossfire.jxclient.gui.item
Definition: GUIItem.java:23