Skip to content

Commit a5a334d

Browse files
committed
Make sure old metods is marked deprecated
1 parent cdef8be commit a5a334d

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

Commands/src/main/java/org/broken/arrow/library/command/CommandRegister.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@
3636
*/
3737
public class CommandRegister implements CommandRegistering {
3838
private final Logging log = new Logging(CommandRegister.class);
39-
4039
private final List<CommandProperty> commandsLegacy = Collections.synchronizedList(new ArrayList<>());
41-
private final Map<String, MainCommandHandler> commandsNew = new ConcurrentHashMap<>();
40+
private final Map<String, MainCommandHandler> commands = new ConcurrentHashMap<>();
4241

4342
private String commandLabelMessage;
4443
private String commandLabelMessageNoPerms;
@@ -63,7 +62,7 @@ public class CommandRegister implements CommandRegistering {
6362
*/
6463
public CommandBuilder registerCommand(final Plugin plugin, final String mainCommand) {
6564
final CommandBuilder commandBuilder = new CommandBuilder();
66-
commandsNew.compute(mainCommand, (s, mainCommandHandler) -> {
65+
commands.compute(mainCommand, (s, mainCommandHandler) -> {
6766
if (mainCommandHandler != null) {
6867
final CommandProperty command = mainCommandHandler.getMainCommand();
6968
final Collection<CommandProperty> commands = mainCommandHandler.getSubcommands();
@@ -95,7 +94,7 @@ public CommandBuilder registerCommand(final Plugin plugin, final String mainComm
9594
public void registerCommand(@Nonnull final Plugin plugin, @Nonnull final String mainCommand, @Nonnull final Consumer<CommandBuilder> callback) {
9695
final CommandBuilder commandBuilder = new CommandBuilder();
9796
callback.accept(commandBuilder);
98-
commandsNew.compute(mainCommand, (s, mainCommandHandler) -> {
97+
commands.compute(mainCommand, (s, mainCommandHandler) -> {
9998
if (mainCommandHandler != null) {
10099
final CommandProperty command = mainCommandHandler.getMainCommand();
101100
final Collection<CommandProperty> commands = mainCommandHandler.getSubcommands();
@@ -117,10 +116,11 @@ public void registerCommand(@Nonnull final Plugin plugin, @Nonnull final String
117116
* @return the returns the settings set for the main command.
118117
*/
119118
public MainCommandHandler getCommand(@Nonnull final String command) {
120-
return commandsNew.get(command.toLowerCase(Locale.ROOT));
119+
return commands.get(command.toLowerCase(Locale.ROOT));
121120
}
122121

123122
@Override
123+
@Deprecated
124124
public CommandRegistering registerSubCommand(final CommandProperty subCommand) {
125125
Set<String> commandLabels = subCommand.getCommandLabels();
126126

@@ -135,6 +135,7 @@ public CommandRegistering registerSubCommand(final CommandProperty subCommand) {
135135
}
136136

137137
@Override
138+
@Deprecated
138139
public CommandRegistering registerSubCommands(final CommandProperty... subCommands) {
139140
if (subCommands == null)
140141
return this;
@@ -150,6 +151,7 @@ public CommandRegistering registerSubCommands(final CommandProperty... subComman
150151
* @return The command label message.
151152
*/
152153
@Override
154+
@Deprecated
153155
public String getCommandLabelMessage() {
154156
return commandLabelMessage;
155157
}
@@ -162,6 +164,7 @@ public String getCommandLabelMessage() {
162164
* @return The CommandRegister instance.
163165
*/
164166
@Override
167+
@Deprecated
165168
public CommandRegistering setCommandLabelMessage(String commandLabelMessage) {
166169
this.commandLabelMessage = commandLabelMessage;
167170
return this;
@@ -173,6 +176,7 @@ public CommandRegistering setCommandLabelMessage(String commandLabelMessage) {
173176
* @return The list of prefix messages.
174177
*/
175178
@Override
179+
@Deprecated
176180
public List<String> getPrefixMessage() {
177181
return prefixMessage;
178182
}
@@ -184,6 +188,7 @@ public List<String> getPrefixMessage() {
184188
* @return The CommandRegistering instance.
185189
*/
186190
@Override
191+
@Deprecated
187192
public CommandRegistering setPrefixMessage(String... prefixMessage) {
188193
this.prefixMessage = Arrays.asList(prefixMessage);
189194
return this;
@@ -196,6 +201,7 @@ public CommandRegistering setPrefixMessage(String... prefixMessage) {
196201
* @return The CommandRegistering instance.
197202
*/
198203
@Override
204+
@Deprecated
199205
public CommandRegistering setPrefixMessage(List<String> prefixMessage) {
200206
this.prefixMessage = prefixMessage;
201207
return this;
@@ -207,6 +213,7 @@ public CommandRegistering setPrefixMessage(List<String> prefixMessage) {
207213
* @return The list of suffix messages.
208214
*/
209215
@Override
216+
@Deprecated
210217
public List<String> getSuffixMessage() {
211218
return suffixMessage;
212219
}
@@ -218,6 +225,7 @@ public List<String> getSuffixMessage() {
218225
* @return The CommandRegistering instance.
219226
*/
220227
@Override
228+
@Deprecated
221229
public CommandRegistering setSuffixMessage(String... suffixMessage) {
222230
this.suffixMessage = Arrays.asList(suffixMessage);
223231
return this;
@@ -230,6 +238,7 @@ public CommandRegistering setSuffixMessage(String... suffixMessage) {
230238
* @return The CommandRegistering instance.
231239
*/
232240
@Override
241+
@Deprecated
233242
public CommandRegistering setSuffixMessage(List<String> suffixMessage) {
234243
this.suffixMessage = suffixMessage;
235244
return this;
@@ -242,11 +251,13 @@ public CommandRegistering setSuffixMessage(List<String> suffixMessage) {
242251
*
243252
* @return The description.
244253
*/
254+
@Deprecated
245255
public List<String> getDescriptions() {
246256
return descriptions;
247257
}
248258

249259
@Override
260+
@Deprecated
250261
public CommandRegistering setDescriptions(final String... descriptions) {
251262
this.descriptions = Arrays.asList(descriptions);
252263
return this;
@@ -258,6 +269,7 @@ public CommandRegistering setDescriptions(final String... descriptions) {
258269
* @return the message or null.
259270
*/
260271
@Override
272+
@Deprecated
261273
public String getCommandLabelMessageNoPerms() {
262274
return commandLabelMessageNoPerms;
263275
}
@@ -269,6 +281,7 @@ public String getCommandLabelMessageNoPerms() {
269281
* @return this class.
270282
*/
271283
@Override
284+
@Deprecated
272285
public CommandRegistering setCommandLabelMessageNoPerms(String commandLabelMessage) {
273286
this.commandLabelMessageNoPerms = commandLabelMessage;
274287
return this;
@@ -280,6 +293,7 @@ public CommandRegistering setCommandLabelMessageNoPerms(String commandLabelMessa
280293
* @return the permission or null if not set.
281294
*/
282295
@Override
296+
@Deprecated
283297
public String getCommandLabelPermission() {
284298
return commandLabelPermission;
285299
}
@@ -291,6 +305,7 @@ public String getCommandLabelPermission() {
291305
* @return this class.
292306
*/
293307
@Override
308+
@Deprecated
294309
public CommandRegistering setCommandLabelPermission(final String commandLabelPermission) {
295310
this.commandLabelPermission = commandLabelPermission;
296311
return this;
@@ -301,6 +316,7 @@ public CommandRegistering setCommandLabelPermission(final String commandLabelPer
301316
*
302317
* @return It returns {@code true} if the command is set.
303318
*/
319+
@Deprecated
304320
public boolean isRegisteredMainCommand() {
305321
return registeredMainCommand;
306322
}
@@ -311,6 +327,7 @@ public boolean isRegisteredMainCommand() {
311327
* @param registeredMainCommand Set it to {@code false } if you want to register more than one main command.
312328
* @return this class for chaining.
313329
*/
330+
@Deprecated
314331
public CommandRegistering setRegisteredMainCommand(final boolean registeredMainCommand) {
315332
this.registeredMainCommand = registeredMainCommand;
316333
return this;
@@ -322,6 +339,7 @@ public CommandRegistering setRegisteredMainCommand(final boolean registeredMainC
322339
* @param subLabel The sub-label of the subcommand to unregister.
323340
*/
324341
@Override
342+
@Deprecated
325343
public void unregisterSubCommand(String subLabel) {
326344
commandsLegacy.forEach(commandBuilder -> commandBuilder.getCommandLabels().removeIf(label -> label.equals(subLabel)));
327345
}
@@ -331,8 +349,10 @@ public void unregisterSubCommand(String subLabel) {
331349
* this list.
332350
*
333351
* @return The list of sub commands.
352+
* @deprecated use {@link #getCommand(String)}
334353
*/
335354
@Override
355+
@Deprecated
336356
public List<CommandProperty> getCommands() {
337357
return Collections.unmodifiableList(commandsLegacy);
338358
}
@@ -342,9 +362,11 @@ public List<CommandProperty> getCommands() {
342362
*
343363
* @param label The sub-label of the command builder to retrieve.
344364
* @return The command builder with the specified sub-label, or null if not found.
365+
* @deprecated use {@link #getCommand(String)}
345366
*/
346367
@Nullable
347368
@Override
369+
@Deprecated
348370
public CommandProperty getCommandBuilder(String label) {
349371
return getCommandBuilder(label, false);
350372
}
@@ -355,9 +377,11 @@ public CommandProperty getCommandBuilder(String label) {
355377
* @param label The sub-label of the command builder to retrieve.
356378
* @param startsWith Specifies whether the sub-label should match the beginning of the command builder's sub-label.
357379
* @return The command builder with the specified sub-label, or null if not found.
380+
* @deprecated use {@link #getCommand(String)}
358381
*/
359382
@Nullable
360383
@Override
384+
@Deprecated
361385
public CommandProperty getCommandBuilder(String label, boolean startsWith) {
362386
for (final CommandProperty command : commandsLegacy) {
363387
if (startsWith && (label.isEmpty() || command.firstLabelMatch(label, true) != null))
@@ -421,6 +445,7 @@ public CommandRegistering registerMainCommand(@Nonnull final String fallbackPref
421445
}
422446

423447
@Override
448+
@Deprecated
424449
public boolean addCommands(CommandProperty subCommand, Set<String> commandLabels) {
425450
if (!commandLabels.isEmpty()) {
426451
for (final String label : commandLabels) {

0 commit comments

Comments
 (0)