Skip to content

Commit 65a95f7

Browse files
committed
Formatting cleanup for dev/example/paper-command-registration
1 parent f9a8dcc commit 65a95f7

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandAPIBukkit.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,12 @@ public void preCommandRegistration(String commandName) {
444444
public void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<Source> resultantNode, List<LiteralCommandNode<Source>> aliasNodes) {
445445
commandRegistrationStrategy.postCommandRegistration(registeredCommand, resultantNode, aliasNodes);
446446

447-
if(!CommandAPI.canRegister()) {
447+
if (!CommandAPI.canRegister()) {
448448
// Adding the command to the help map usually happens in `CommandAPIBukkit#onEnable`
449449
updateHelpForCommands(List.of(registeredCommand));
450450

451451
// Sending command dispatcher packets usually happens when Players join the server
452-
for(Player p: Bukkit.getOnlinePlayers()) {
452+
for (Player p : Bukkit.getOnlinePlayers()) {
453453
p.updateCommands();
454454
}
455455
}
@@ -471,9 +471,9 @@ public void unregister(String commandName, boolean unregisterNamespaces) {
471471
*
472472
* @param commandName the name of the command to unregister
473473
* @param unregisterNamespaces whether the unregistration system should attempt to remove versions of the
474-
* command that start with a namespace. E.g. `minecraft:command`, `bukkit:command`,
475-
* or `plugin:command`. If true, these namespaced versions of a command are also
476-
* unregistered.
474+
* command that start with a namespace. E.g. `minecraft:command`, `bukkit:command`,
475+
* or `plugin:command`. If true, these namespaced versions of a command are also
476+
* unregistered.
477477
* @param unregisterBukkit whether the unregistration system should unregister Vanilla or Bukkit commands. If true,
478478
* only Bukkit commands are unregistered, otherwise only Vanilla commands are unregistered.
479479
* For the purposes of this parameter, commands registered using the CommandAPI are Vanilla
@@ -488,7 +488,7 @@ private void unregisterInternal(String commandName, boolean unregisterNamespaces
488488

489489
commandRegistrationStrategy.unregister(commandName, unregisterNamespaces, unregisterBukkit);
490490

491-
if(!CommandAPI.canRegister()) {
491+
if (!CommandAPI.canRegister()) {
492492
// Help topics (from Bukkit and CommandAPI) are only setup after plugins enable, so we only need to worry
493493
// about removing them once the server is loaded.
494494
getHelpMap().remove("/" + commandName);
@@ -631,5 +631,4 @@ boolean isInvalidNamespace(String commandName, String namespace) {
631631
}
632632
return false;
633633
}
634-
635634
}

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandRegistrationStrategy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public abstract class CommandRegistrationStrategy<Source> {
3232

3333
// Utility methods
3434
protected void removeBrigadierCommands(CommandDispatcher<Source> dispatcher, String commandName,
35-
boolean unregisterNamespaces, Predicate<CommandNode<Source>> extraCheck) {
35+
boolean unregisterNamespaces, Predicate<CommandNode<Source>> extraCheck) {
3636
RootCommandNode<?> root = dispatcher.getRoot();
3737
Map<String, CommandNode<Source>> children = (Map<String, CommandNode<Source>>) commandNodeChildren.get(root);
3838
Map<String, CommandNode<Source>> literals = (Map<String, CommandNode<Source>>) commandNodeLiterals.get(root);
@@ -66,9 +66,9 @@ protected static <T> void removeCommandFromMapIfCheckPasses(Map<String, T> map,
6666
}
6767

6868
protected static boolean isThisTheCommandButNamespaced(String commandName, String key) {
69-
if(!key.contains(":")) return false;
69+
if (!key.contains(":")) return false;
7070
String[] split = key.split(":");
71-
if(split.length < 2) return false;
71+
if (split.length < 2) return false;
7272
return split[1].equalsIgnoreCase(commandName);
7373
}
7474

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/SpigotCommandRegistration.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private void fixPermissions() {
124124
* what are you doing and why?
125125
*/
126126
Command command = map.getCommand(cmdName);
127-
if(command != null && commandAPIBukkit.isVanillaCommandWrapper(command)) {
127+
if (command != null && commandAPIBukkit.isVanillaCommandWrapper(command)) {
128128
command.setPermission(permNode);
129129
}
130130
}
@@ -135,7 +135,7 @@ private void fixPermissions() {
135135
@Override
136136
public void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<Source> resultantNode, List<LiteralCommandNode<Source>> aliasNodes) {
137137

138-
if(!CommandAPI.canRegister()) {
138+
if (!CommandAPI.canRegister()) {
139139
// Usually, when registering commands during server startup, we can just put our commands into the
140140
// `net.minecraft.server.MinecraftServer#vanillaCommandDispatcher` and leave it. As the server finishes setup,
141141
// it and the CommandAPI do some extra stuff to make everything work, and we move on.
@@ -250,7 +250,7 @@ private void fillNamespacesToFix(String... namespacedCommands) {
250250
// and there is already a command with this name in the dispatcher
251251
// then, the command currently in the dispatcher is supposed to appear as `minecraft:command`
252252
CommandNode<Source> currentNode = brigadierDispatcher.getRoot().getChild(namespacedCommand);
253-
if(currentNode != null) {
253+
if (currentNode != null) {
254254
// We'll keep track of everything that should be `minecraft:command` in
255255
// `minecraftCommandNamespaces` and fix this later in `#fixNamespaces`
256256
// TODO: Ideally, we should be working without this cast to LiteralCommandNode. I don't know if this can fail
@@ -261,7 +261,7 @@ private void fillNamespacesToFix(String... namespacedCommands) {
261261

262262
@Override
263263
public void unregister(String commandName, boolean unregisterNamespaces, boolean unregisterBukkit) {
264-
if(!unregisterBukkit) {
264+
if (!unregisterBukkit) {
265265
// Remove nodes from the Vanilla dispatcher
266266
// This dispatcher doesn't usually have namespaced version of commands (those are created when commands
267267
// are transferred to Bukkit's CommandMap), but if they ask, we'll do it
@@ -271,7 +271,7 @@ public void unregister(String commandName, boolean unregisterNamespaces, boolean
271271
CommandAPIHandler.getInstance().writeDispatcherToFile();
272272
}
273273

274-
if(unregisterBukkit || !CommandAPI.canRegister()) {
274+
if (unregisterBukkit || !CommandAPI.canRegister()) {
275275
// We need to remove commands from Bukkit's CommandMap if we're unregistering a Bukkit command, or
276276
// if we're unregistering after the server is enabled, because `CraftServer#setVanillaCommands` will have
277277
// moved the Vanilla command into the CommandMap
@@ -280,14 +280,14 @@ public void unregister(String commandName, boolean unregisterNamespaces, boolean
280280
// If we are unregistering a Bukkit command, DO NOT unregister VanillaCommandWrappers
281281
// If we are unregistering a Vanilla command, ONLY unregister VanillaCommandWrappers
282282
boolean isMainVanilla = commandAPIBukkit.isVanillaCommandWrapper(knownCommands.get(commandName));
283-
if(unregisterBukkit ^ isMainVanilla) knownCommands.remove(commandName);
283+
if (unregisterBukkit ^ isMainVanilla) knownCommands.remove(commandName);
284284

285-
if(unregisterNamespaces) {
285+
if (unregisterNamespaces) {
286286
removeCommandNamespace(knownCommands, commandName, c -> unregisterBukkit ^ commandAPIBukkit.isVanillaCommandWrapper(c));
287287
}
288288
}
289289

290-
if(!CommandAPI.canRegister()) {
290+
if (!CommandAPI.canRegister()) {
291291
// If the server is enabled, we have extra cleanup to do
292292

293293
// Remove commands from the resources dispatcher

0 commit comments

Comments
 (0)