From 79ec9e65697a6ae2c128963ea36a564eab96db97 Mon Sep 17 00:00:00 2001 From: LeoDog896 Date: Tue, 9 Feb 2021 09:26:53 -0500 Subject: [PATCH] Add null checks for aliases --- .../net/minestom/server/command/CommandManager.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minestom/server/command/CommandManager.java b/src/main/java/net/minestom/server/command/CommandManager.java index 2dad50fd4..10c1cb2a5 100644 --- a/src/main/java/net/minestom/server/command/CommandManager.java +++ b/src/main/java/net/minestom/server/command/CommandManager.java @@ -67,9 +67,11 @@ public final class CommandManager { public synchronized void register(@NotNull Command command) { Check.stateCondition(commandExists(command.getName()), "A command with the name " + command.getName() + " is already registered!"); - for (String alias : command.getAliases()) { - Check.stateCondition(commandExists(alias), - "A command with the name " + alias + " is already registered!"); + if (command.getAliases() != null) { + for (String alias : command.getAliases()) { + Check.stateCondition(commandExists(alias), + "A command with the name " + alias + " is already registered!"); + } } this.dispatcher.register(command); } @@ -315,6 +317,9 @@ public final class CommandManager { int mainNodeIndex = createCommand(player, nodes, cmdChildren, command.getName(), syntaxes, rootChildren); // Use redirection to hook aliases with the command + if (command.getAliases() == null) + continue; + for (String alias : command.getAliases()) { DeclareCommandsPacket.Node node = new DeclareCommandsPacket.Node(); node.flags = getFlag(NodeType.LITERAL, false, true, false);