|
@@ -45,6 +45,8 @@ public class AliasManager {
|
45
|
45
|
private final CommandController commandController;
|
46
|
46
|
/** Map of known alias names to their corresponding aliases. */
|
47
|
47
|
private final Map<String, Alias> aliases = new ConcurrentSkipListMap<>();
|
|
48
|
+ /** Whether or not changes have been made compared to the stored version. */
|
|
49
|
+ private boolean dirty;
|
48
|
50
|
|
49
|
51
|
@Inject
|
50
|
52
|
public AliasManager(final CommandController commandController) {
|
|
@@ -65,6 +67,7 @@ public class AliasManager {
|
65
|
67
|
|
66
|
68
|
aliases.put(alias.getName(), alias);
|
67
|
69
|
commandController.registerCommand(new AliasCommandHandler(commandController, alias), alias);
|
|
70
|
+ dirty = true;
|
68
|
71
|
}
|
69
|
72
|
|
70
|
73
|
/**
|
|
@@ -77,6 +80,7 @@ public class AliasManager {
|
77
|
80
|
public void removeAlias(final Alias alias) {
|
78
|
81
|
if (aliases.containsKey(alias.getName())) {
|
79
|
82
|
commandController.unregisterCommand(aliases.remove(alias.getName()));
|
|
83
|
+ dirty = true;
|
80
|
84
|
}
|
81
|
85
|
}
|
82
|
86
|
|
|
@@ -90,6 +94,7 @@ public class AliasManager {
|
90
|
94
|
public void removeAlias(final String name) {
|
91
|
95
|
if (aliases.containsKey(name)) {
|
92
|
96
|
removeAlias(aliases.get(name));
|
|
97
|
+ dirty = true;
|
93
|
98
|
}
|
94
|
99
|
}
|
95
|
100
|
|
|
@@ -122,4 +127,22 @@ public class AliasManager {
|
122
|
127
|
return Optional.fromNullable(aliases.get(name));
|
123
|
128
|
}
|
124
|
129
|
|
|
130
|
+ /**
|
|
131
|
+ * Gets the dirty state of the manager.
|
|
132
|
+ *
|
|
133
|
+ * @return True if the manager is dirty with respect to the store, false otherwise.
|
|
134
|
+ */
|
|
135
|
+ public boolean isDirty() {
|
|
136
|
+ return dirty;
|
|
137
|
+ }
|
|
138
|
+
|
|
139
|
+ /**
|
|
140
|
+ * Manually sets the dirty state of the manager. This should be done after the manager's
|
|
141
|
+ * aliases are loaded or saved.
|
|
142
|
+ *
|
|
143
|
+ * @param dirty True if the manager is now dirty with respect to the store, false otherwise.
|
|
144
|
+ */
|
|
145
|
+ public void setDirty(final boolean dirty) {
|
|
146
|
+ this.dirty = dirty;
|
|
147
|
+ }
|
125
|
148
|
}
|