Skip to content

Commit fd2b8ae

Browse files
committed
Fix: Handle NPE when unregistering commands
Wraps 'Chat.getCommandManager().unregisterCommand(name)' in a try-catch block to suppress NullPointerExceptions that can occur if the command dispatcher is not currently active (e.g., during certain initialization phases or server connections).
1 parent a30fe0c commit fd2b8ae

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libs/CommandBuilderWrapper.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ export class RootNode extends CommandNode {
316316

317317
export class CommandManager {
318318
static create(name: string): RootNode {
319-
Chat.getCommandManager().unregisterCommand(name);
319+
try {
320+
Chat.getCommandManager().unregisterCommand(name);
321+
} catch (e) {}
320322
return new RootNode(name);
321323
}
322324
}

0 commit comments

Comments
 (0)