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

Skip to content

Commit 142b598

Browse files
committed
Provide compatibilty with #417
1 parent e4a159f commit 142b598

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
@@ -483,7 +483,7 @@ public void preCommandRegistration(String commandName) {
483483
}
484484

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

505505
// Adding permissions to these Commands usually happens in `CommandAPIBukkit#onEnable`
506506
command.setPermission(permNode);
507507

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

512512
// Do the same for the aliases
513513
for(LiteralCommandNode<Source> node: aliasNodes) {
514514
command = wrapToVanillaCommandWrapper(node);
515-
map.register("minecraft", command);
515+
map.register(namespace, command);
516516

517517
command.setPermission(permNode);
518518

519519
root.addChild(node);
520-
root.addChild(namespaceNode(node));
520+
root.addChild(namespaceNode(node, namespace));
521521
}
522522

523523
// Adding the command to the help map usually happens in `CommandAPIBukkit#onEnable`
@@ -530,10 +530,10 @@ public void postCommandRegistration(RegisteredCommand registeredCommand, Literal
530530
}
531531
}
532532

533-
private LiteralCommandNode<Source> namespaceNode(LiteralCommandNode<Source> original) {
533+
private LiteralCommandNode<Source> namespaceNode(LiteralCommandNode<Source> original, String namespace) {
534534
// Adapted from a section of `CraftServer#syncCommands`
535535
LiteralCommandNode<Source> clone = new LiteralCommandNode<>(
536-
"minecraft:" + original.getLiteral(),
536+
namespace + ":" + original.getLiteral(),
537537
original.getCommand(),
538538
original.getRequirement(),
539539
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