8000 Provide compatibilty with #417 · CommandAPI/CommandAPI@3708181 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3708181

Browse files
committed
Provide compatibilty with #417
1 parent 38f0667 commit 3708181

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

commandapi-core/src/main/java/dev/jorel/commandapi/CommandAPIHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ void register(CommandMetaData<CommandSender> meta, final Argument[] args,
682682
// partial) command registration. Generate the dispatcher file!
683683
writeDispatcherToFile();
684684

685-
platform.postCommandRegistration(registeredCommandInformation, resultantNode, aliasNodes);
685+
platform.postCommandRegistration(registeredCommandInformation, resultantNode, aliasNodes, namespace);
686686
}
687687

688688
/**

commandapi-core/src/main/java/dev/jorel/commandapi/CommandAPIPlatform.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ public interface CommandAPIPlatform<Argument
101101
* @param registeredCommand A {@link RegisteredCommand} instance that holds the CommandAPI information for the command
102102
* @param resultantNode The node that was registered
103103
* @param aliasNodes Any alias nodes that were also registered as a part of this registration process
104+
* @param namespace The command namespace
104105
*/
105-
public abstract void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<Source> resultantNode, List<LiteralCommandNode<Source>> aliasNodes);
106+
public abstract void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<Source> resultantNode, List<LiteralCommandNode<Source>> aliasNodes, String namespace);
106107

107108
/**
108109
* Registers a Brigadier command node and returns the built node.

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ public void preCommandRegistration(String commandName) {
486486
}
487487

488488
@Override
489-
public void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<Source> resultantNode, List<LiteralCommandNode<Source>> aliasNodes) {
489+
public void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<Source> resultantNode, List<LiteralCommandNode<Source>> aliasNodes, String namespace) {
490490
if(!CommandAPI.canRegister()) {
491491
// Usually, when registering commands during server startup, we can just put our commands into the
492492
// `net.minecraft.server.MinecraftServer#vanillaCommandDispatcher` and leave it. As the server finishes setup,
@@ -503,24 +503,24 @@ public void postCommandRegistration(RegisteredCommand registeredCommand, Literal
503503
// Wrapping Brigadier nodes into VanillaCommandWrappers and putting them in the CommandMap usually happens
504504
// in `CraftServer#setVanillaCommands`
505505
Command command = wrapToVanillaCommandWrapper(resultantNode);
506-
map.register("minecraft", command);
506+
map.register(namespace, command);
507507

508508
// Adding permissions to these Commands usually happens in `CommandAPIBukkit#onEnable`
509509
command.setPermission(permNode);
510510

511511
// Adding commands to the other (Why bukkit/spigot?!) dispatcher usually happens in `CraftServer#syncCommands`
512512
root.addChild(resultantNode);
513-
root.addChild(namespaceNode(resultantNode));
513+
root.addChild(namespaceNode(resultantNode, namespace));
514514

515515
// Do the same for the aliases
516516
for(LiteralCommandNode<Source> node: aliasNodes) {
517517
command = wrapToVanillaCommandWrapper(node);
518-
map.register("minecraft", command);
518+
map.register(namespace, command);
519519

520520
command.setPermission(permNode);
521521

522522
root.addChild(node);
523-
root.addChild(namespaceNode(node));
523+
root.addChild(namespaceNode(node, namespace));
524524
}
525525

526526
// Adding the command to the help map usually happens in `CommandAPIBukkit#onEnable`
@@ -533,10 +533,10 @@ public void postCommandRegistration(RegisteredCommand registeredCommand, Literal
533533
}
534534
}
535535

536-
private LiteralCommandNode<Source> namespaceNode(LiteralCommandNode<Source> original) {
536+
private LiteralCommandNode<Source> namespaceNode(LiteralCommandNode<Source> original, String namespace) {
537537
// Adapted from a section of `CraftServer#syncCommands`
538538
LiteralCommandNode<Source> clone = new LiteralCommandNode<>(
539-
"minecraft:" + original.getLiteral(),
539+
namespace + ":" + original.getLiteral(),
540540
original.getCommand(),
541541
original.getRequirement(),
542542
original.getRedirect(),

commandapi-platforms/commandapi-sponge/commandapi-sponge-core/src/main/java/dev/jorel/commandapi/CommandAPISponge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void preCommandRegistration(String commandName) {
129129
}
130130

131131
@Override
132-
public void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<Object> resultantNode, List<LiteralCommandNode<Object>> aliasNodes) {
132+
public void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<Object> resultantNode, List<LiteralCommandNode<Object>> aliasNodes, String namespace) {
133133
// Nothing to do?
134134
}
135135

commandapi-platforms/commandapi-velocity/commandapi-velocity-core/src/main/java/dev/jorel/commandapi/CommandAPIVelocity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void preCommandRegistration(String commandName) {
210210
}
211211

212212
@Override
213-
public void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<CommandSource> resultantNode, List<LiteralCommandNode<CommandSource>> aliasNodes) {
213+
public void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<CommandSource> resultantNode, List<LiteralCommandNode<CommandSource>> aliasNodes, String namespace) {
214214
// Nothing to do
215215
}
216216

0 commit comments

Comments
 (0)
0