23 package com.realtime.crossfire.jxclient.shortcuts;
30 import java.nio.file.Path;
31 import java.util.Collections;
32 import java.util.EnumMap;
33 import java.util.Iterator;
35 import java.util.Map.Entry;
36 import org.jetbrains.annotations.NotNull;
37 import org.jetbrains.annotations.Nullable;
43 public class Shortcuts implements Iterable<Shortcut> {
74 @SuppressWarnings(
"FieldCanBeLocal")
78 public void spellAdded(
final int index) {
79 for (
final Entry<ShortcutSlot, Shortcut> e :
shortcuts.entrySet()) {
80 final Shortcut shortcut = e.getValue();
81 if (shortcut !=
null) {
88 public void spellRemoved(
final int index) {
89 for (
final Entry<ShortcutSlot, Shortcut> e :
shortcuts.entrySet()) {
90 final Shortcut shortcut = e.getValue();
91 if (shortcut !=
null) {
117 if (shortcut !=
null) {
119 listener.shortcutRemoved(shortcutSlot, shortcut);
144 final String command2 = command.trim();
145 @Nullable
final Spell spell;
146 if (command2.isEmpty()) {
148 }
else if (command2.startsWith(
"cast ")) {
150 }
else if (command2.startsWith(
"invoke ")) {
157 if (oldShortcut !=
null) {
159 listener.shortcutRemoved(shortcutSlot, oldShortcut);
163 final Shortcut newShortcut = command2.isEmpty() ? null :
new Shortcut(command2, spell);
164 shortcuts.put(shortcutSlot, newShortcut);
165 if (newShortcut !=
null) {
167 listener.shortcutAdded(shortcutSlot, newShortcut);
171 if (saveChanges &&
file !=
null) {