SpigotMap implements PlatformMap { @Override public @Nullable DispatcherCommand register(LiteralCommandNode<CommandSender> command) { if (map.getKnownCommands().containsKey(command.getName())) { return null; } var wrapped = wrap(command); map.register(prefix, wrapped); return wrapped; } SpigotMap(String prefix, Plugin plugin, CraftCommandMap map); @Override @Nullable DispatcherCommand register(LiteralCommandNode<CommandSender> command); @Override @Nullable DispatcherCommand unregister(String name);  }
@Test void register() { var command = map.register(literal); verify(craftmap).register(PREFIX, command); assertEquals("literal", command.getName()); assertEquals("literal", command.getUsage()); assertEquals(plugin, command.getPlugin()); assertEquals(dispatcher, command.dispatcher); assertEquals(List.of("l"), command.getAliases()); }
@Test void register_already_exists() { craftmap.getKnownCommands().put("literal", mock(Command.class)); assertNull(map.register(literal)); verify(craftmap, times(0)).register(eq(PREFIX), any(Command.class)); }